【发布时间】:2011-03-31 15:37:28
【问题描述】:
我想对从数组中调用的精灵进行分组,以便将它们作为一个组移动。有人告诉我使用 cocosnode,但我很确定他的意思是 ccnode。到目前为止,这是我的代码:
sprites1 = (CCSprite *)[c1array objectAtIndex:0];
sprites2 = (CCSprite *)[c1array objectAtIndex:1];
sprites3 = (CCSprite *)[c1array objectAtIndex:2];
sprites4 = (CCSprite *)[c1array objectAtIndex:3];
sprites5 = (CCSprite *)[c1array objectAtIndex:4];
sprites6 = (CCSprite *)[c1array objectAtIndex:5];
sprites7 = (CCSprite *)[c1array objectAtIndex:6];
sprites8 = (CCSprite *)[c1array objectAtIndex:7];
column1 = [CCNode node];
[column1 addChild:sprites1];
[column1 addChild:sprites2];
[column1 addChild:sprites3];
[column1 addChild:sprites4];
column1.position = ccp(0,0);
[self addChild:column1];
column2 = [CCNode node];
[column2 addChild:sprites5];
[column2 addChild:sprites6];
[column2 addChild:sprites7];
[column2 addChild:sprites8];
column2.position = ccp(30,0);
[self addChild:column2];
//ccotouchmoved code
column1.anchorPoint = ccp(touchLocation.x,touchLocation.y);
if (CGRectContainsPoint(c1,touchLocation)) {
touchLocation.x = column1.position.x;
column1.position = ccp(touchLocation.x,touchLocation.y);
}
如何使 ccnode 顺利移动。它跳了很多,但我想要一个平稳的上下过渡。
xxx
xxx
xxx
x 是我的精灵,我正在将我的 x 作为一整列上下移动,并且需要能够将我的 x 作为一整行移动,一旦它离开屏幕顶部,我需要它重新出现在屏幕的另一侧,反之亦然,左右相同。
【问题讨论】:
-
崩溃时出现什么错误?
标签: objective-c cocos2d-iphone grouping sprite