Attention Topic was automatically imported from the old Question2Answer platform.

i try this tutorial.but this code not work in 3.1 stable.
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 img=[]
var move =Vector2(0,0);var speed=4

for n in range(16):
img.append(imgNode.instance())
img[n].set_frame(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));
``````

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

thanks,there are no more error

bgegg | 2019-04-04 01:52