Question

I have a problem regarding with the touch and move. I want to move a sprite by following the set of touches but it moves in different ways when i clicked many times.

here's my code so far:

    moveObject : function(position){
    var moveTest =cc.MoveTo.create(1, position);
    var spriteMove = this.sprite;
    spriteMove.runAction(moveTest);
},
onMouseUp : function (event) {
    var location = event.getLocation();
    this.moveObject(location);
},

What can I add more to this to queue the moveby action?

Was it helpful?

Solution

actions need time to complete, they aren't good to use for touch & move since a new mouse event may be coming in every frame. In your example you aren't even stopping any previously running move actions, which means they'll invalidate each other's movements. Even if you would stop the previous move action, when events are fired every frame the sprite won't move at all because the action had no time to even start running yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top