Cocossharp CCMoveTo issue

Why I want to do is move nodes to the bottom after a player clicks one. Each node should be to the right of the previous one.

If the player doesn't click too fast, this works fine. But when the player clicks nodes fast (before the previous finished moving), the nodes would overlap so I kept a list of all the pending ones and added that distance to the last position, this adds to much spacing by approximately 1 space to far apart.

CCNode node = sender as CCNode;
node.RemoveFromParent();
var pos = holder.GetNextAvailablePosition(); // Finds the position of the furthest right node.
holder.AddChild(node);
var time = .5f;
var scaleBy = .5f;
var nodeSize = 180f;
pos += new CCPoint(pendingNodes.Count * (nodeSize * scaleBy), 0);
var move = new CCMoveTo(time, pos);
var scale = new CCScaleTo(time, scaleBy);
pendingNodes.Push(node);
await node.RunActionAsync(new CCSequence(move, scale, new CCCallFunc(() =>
{
    pendingNodes.Pop();
})));

The other thing I need to figure out is how to prevent the node from changing position when it gets reparented. I reparent the node to change it's Z order.

Tagged:

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    Could you please post a basic demo so that we can tested with it?

Sign In or Register to comment.