please help about 15 puzzle.old code does not work.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By bgegg

https://www.youtube.com/watch?v=I7b9APTt6MY
i try this tutorial.but this code not work in 3.1 stable.
i god some advice this thread.
are you know tutorial of 15 puzzle(sliding puzzle)? - Archive - Godot Forum

I fixed some things but still have problems.
The set_pos function results in an error.
This has been replaced by set_position.
Also, set_hidden is an error. What should this replace?
I saw the node2d reference but I do not know.

i copy this code on youtube.
extends Node2D

    var map=[[0,1,2,3],[4,5,6,7],[8,9,10,11],[11,12,13,14]]
    var imgNode = preload("res://levels/0_img.tscn")
    var img=[]
    var move =Vector2(0,0);var speed=4
    
    func _ready():
    	for n in range(16):
    		img.append(imgNode.instance())
    		img[n].set_frame(n)
    		add_child(img[n])
    		for y in range(4):
    			if map[y].find(n) != -1:
    				img[n].set_pos(Vector2(map[y].find(n)*100, y*100))
    	img[15].set_hidden(true)
    	set_physics_process(true)
    	
    func step(key,dir):
    	if Input.is_key_pressed(key) and move == Vector2(0,0) or move == dir:
    			for y in range(4):
    				if map[y].find(15) != -1:
    					var pos = Vector2(y,map[y].find(15)) +dir
    					pos.x = min(max(pos.x,0),3);pos.y = min(max(pos.y,0),3)
    					img[map[y][map[y].find(15)]].set_pos(Vector2(pos.y * 100,pos.x * 100))
    					if img[map[pos.x][pos.y]].get_pos() != Vector2(map[y].find(15)*100,y*100):
    						move = dir
    						img[map[pos.x][pos.y]].set_position(img[map[pos.x][pos.y]].get_pos() - Vector2(dir.y * speed,dir.x * speed))
    					else : map[y][map[y].find(15)] = map[pos.x][pos.y];map[pos.x][pos.y] = 15;move = Vector2(0,0)
    					break
    func fixed_process(delta):
    	step(KEY_DOWN,Vector2(-1,0));
    	step(KEY_RIGHT,Vector2(0,-1));
    	step(KEY_LEFT,Vector2(0,1));
    	step(KEY_UP,Vector2(1,0));
:bust_in_silhouette: Reply From: volzhs

node.set_visible(value) or node.visible = value

thanks,there are no more error

bgegg | 2019-04-04 01:52