【发布时间】:2013-10-01 14:10:47
【问题描述】:
作为 cocos2d 的新手,我现在被粉刷了,我需要在触摸开始时更改精灵的图像(从精灵表中,我也没有使用 .plist 作为坐标),因此为此我使用了以下代码
elfSheet = [CCSpriteBatchNode batchNodeWithFile:@"BowSpritesheet.png" capacity:12];
[self addChild:elfSheet];
elfFrame1 = [CCSpriteFrame frameWithTexture:elfSheet.texture rect:
CGRectMake(0, 0, 128, 140)]; //elf run00001.png
elfFrame2 = [CCSpriteFrame frameWithTexture:elfSheet.texture rect:
CGRectMake(128, 0, 110, 140)]; //elf run00002.png
Bow = [CCSprite spriteWithTexture:elfFrame1.texture rect:elfFrame1.rect];
Bow.position=ccp(size.width/8, size.height/5);
[elfSheet addChild:Bow z:0];
这里elfSheet 是CCSpriteBatchNode
现在在 cctouches 开始我需要将精灵帧更改为 elfFrame2 当我尝试设置显示帧时它会造成崩溃
-(void)ccTouchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[Bow setDisplayFrame:elfFrame2];//Creates a crash
}
请帮助我解决这个问题
提前致谢
【问题讨论】:
标签: ios cocos2d-iphone