im trying to make a sprite go somewhere, but when i hit an arrowkey, the sprite goes back to where it was
update: function (dt) {
var a = a;
var b = b;
var c = c;
var thing = app.root.findByName('pointer');
var port = thing.getPosition();
var command = null;
if(app.keyboard.wasPressed(17)){
command = prompt('Type your command.','');
switch(command){
case('10110'): this.entity.translate(port.x,port.y,0);
break;
}
}
}//no touch
I believe the problem is because you’re calling setPosition on an entity that has a dynamic rigidbody component. If you do this, the physics simulation is not being told that they rididbody needs to be relocated. So instead of calling setPosition, call pc.RigidbodyComponent#teleport: