Hey guys, I'm a bit new to this and I was trying to create simple snake game, but at the stage of one moving pixel I realised that when I'm attempting to modify position of individual parts by calling their function, according to what program reads through print function position changes, but on the screen there is no effect.
In order to check what is happening I connected another timer to the snakepart node and connected it to its another function which is not called from the outside. This way it displays on the screen,
so _on_Timer_timeout() from Snakepart actually works, but similar function: move() doesn't seem to work properly and seems to modify something else. When I wanted to check the changes by "remote" screen, it just displayed message "select a single node to edit it's signals and groups" when I attempted to select a node. I'd like to ask what exacly I am modifying in the move() function and what is the good way handle modifying multiple childrens position without invoking their functions
Snake node code:
extends Node2D
onready var snakepart= load("res://snake/snakepart.tscn")
var snake_body= {}
var need_to_grow= false
func _ready():
grow()
func grow():
if snake_body.empty():
snake_body[1]= (snakepart.instance())
add_child(snakepart.instance())
else:
need_to_grow= true
# will be handled during the movement
func _on_Timer_timeout():
snake_body[1].move()
snakepart code:
extends Area2D
func move():
position+= Vector2(8, 0)
print(position)
func _on_Timer_timeout():
position+= Vector2(0, 8)
print(position)
I send images of printed result on console and nodes:
