Cocos2d iphone cocos2d移动精灵?

Cocos2d iphone cocos2d移动精灵?,cocos2d-iphone,Cocos2d Iphone,需要一些建议/指向正确的方向来解决这个问题。。学童。。不是作业!!个人学习。我不知道如何让唾液从上到下流动。下面的代码使它们从左到右。提前谢谢 CCSprite * monster = [CCSprite spriteWithFile:@"image.png"]; // Determine where to spawn the monster along the Y axis CGSize winSize = [CCDirector sharedDirector].winSize; int m

需要一些建议/指向正确的方向来解决这个问题。。学童。。不是作业!!个人学习。我不知道如何让唾液从上到下流动。下面的代码使它们从左到右。提前谢谢

 CCSprite * monster = [CCSprite spriteWithFile:@"image.png"];
// Determine where to spawn the monster along the Y axis
CGSize winSize = [CCDirector sharedDirector].winSize;
int minX = monster.contentSize.width/ 0.2;
int maxX = winSize.height - monster1.contentSize.width/2;
int rangeX = maxX - minX;
int actualX = (arc4random() % rangeX) + minX;

// Create the monster slightly off-screen along the right edge,
// and along a random position along the Y axis as calculated above
monster.position = ccp(winSize1.width + monster.contentSize.width/2, actualX);
[self addChild:monster1];

// Determine speed of the monster
int minDuration = 2.0;
int maxDuration = 4.0;
int rangeDuration = maxDuration - minDuration;
int actualDuration = (arc4random() % rangeDuration) + minDuration;

// Create the actions
CCMoveTo * actionMove = [CCMoveTo actionWithDuration:actualDuration
                                            position:ccp(-monster.contentSize.width/2, actualX)];
CCCallBlockN * actionMoveDone = [CCCallBlockN actionWithBlock:^(CCNode *node) {
    [node removeFromParentAndCleanup:YES];
}];
[monster1 runAction:[CCSequence actions:actionMove, actionMoveDone, nil]];

这句话是这样说的:

CCMoveTo * actionMove = [CCMoveTo actionWithDuration:actualDuration position:ccp(-monster.contentSize.width/2, actualX)];
是什么在推动这场运动。您告诉精灵移动到的位置,
ccp(-monster.contentSize.width/2,actualX)
,是您要移动到的位置的(X,Y)坐标。X是第一个值,Y是第二个值。由于某些原因,您希望移动到的位置的Y值中有
actualX

如果要向上或向下移动,应将精灵移动到新的Y坐标。也许是这样的

CCMoveTo * actionMove = [CCMoveTo actionWithDuration:actualDuration position:ccp(monster.position.x, monster.position.y - 300)];