문제

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?

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top