私は自分のゲームに別のレベルを追加しようとしています。プレイ中のゲームのスコアは上がり、一定のスコアに達するとレベルが変更されます。それは私の計画でしたが、私はあなたが見ることができるようにコードとif 'spiderupdate:(cctime)delta'のようなコードを書いていました。私は確かに問題があると確信しています。私はそこに 'もし'を入れて1つのレベルしか使用しないと、クラッシュすることなく動作します。 誰でも私にそれを修正する方法を理解するのを助けることができます。私のアプリでNSInvalidArgumentExceptionエラーが発生しました...これで助けてください助けてください。
とエラーこの「NSInvalidArgumentException」、理由のようです:「 - [テクスチャを再生する]:認識されていないセレクタはインスタンス0xf57da10に送信された」
プレイは私のクラス名と質感がメソッドであるべきであるが、私はいずれかを持っていませんテクスチャという名前のメソッド。ここで
-(void) spidersUpdate:(ccTime)delta {
// Try to find a spider which isn't currently moving.
for (int i = 0; i < 10; i++)
{
int randomSpiderIndex = CCRANDOM_0_1() * [spiders count];
CCSprite* spider = [spiders objectAtIndex:randomSpiderIndex];
// If the spider isn't moving it won’t have any running actions.
if ([spider numberOfRunningActions] == 0)
{
if(currentScore<=30)
[self level1:spider];
else if(31<=currentScore<=60)
[self level2:spider];
else if (61<=currentScore<=90) {
[self level3:spider];
}
else if (91<=currentScore<=120) {
[self level4:spider];
}
else if (120<=currentScore) {
[self level5:spider];
}
break;
// Only one spider should start moving at a time.
}
}
}
-(void) level1:(CCSprite*)spider {
// Slowly increase the spider speed over time.
numSpidersMoved++;
if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f) {
spiderMoveDuration -= 0.2f; }
CGPoint belowScreenPosition = CGPointMake(spider.position.x,
-10);
CCMoveTo* move = [CCMoveTo actionWithDuration:spiderMoveDuration
position:belowScreenPosition];
CCCallFuncN* callDidDrop =[CCCallFuncN actionWithTarget:self selector:@selector(spiderDidDrop:)];
CCSequence* sequence = [CCSequence actions:move, callDidDrop, nil];
if ([spider runAction:sequence])
{
currentScore++;
}
}
-(void) level2:(CCSprite*)spider
{
numSpidersMoved++;
if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f) {
spiderMoveDuration -= 0.2f; }
// Slowly increase the spider speed over time.
CGPoint belowScreenPosition = CGPointMake(spider.position.x,
-10);
CCMoveTo* move = [CCMoveTo actionWithDuration:spiderMoveDuration position:belowScreenPosition];
CCActionEase*esay=[CCEaseExponentialIn actionWithAction:move];
CCCallFuncN* callDidDrop =[CCCallFuncN actionWithTarget:self selector:@selector(spiderDidDrop:)];
CCSequence* sequence = [CCSequence actions:esay, callDidDrop, nil];
if ([spider runAction:sequence])
{
currentScore++;
}
}
-(void) level3:(CCSprite*)spider
{
numSpidersMoved++;
if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f) {
spiderMoveDuration -= 0.2f; }
// Slowly increase the spider speed over time.
CGPoint belowScreenPosition = CGPointMake(spider.position.x,
-10);
CCMoveTo* move = [CCMoveTo actionWithDuration:spiderMoveDuration position:belowScreenPosition];
CCActionEase*esay=[CCEaseExponentialInOut actionWithAction:move];
CCCallFuncN* callDidDrop =[CCCallFuncN actionWithTarget:self selector:@selector(spiderDidDrop:)];
CCSequence* sequence = [CCSequence actions:esay, callDidDrop, nil];
if ([spider runAction:sequence])
{
currentScore++;
}
}
-(void) level4:(CCSprite*)spider
{
numSpidersMoved++;
if (numSpidersMoved % 8 == 0 && spiderMoveDuration > 2.0f) {
spiderMoveDuration -= 0.2f; }
// Slowly increase the spider speed over time.
CGPoint belowScreenPosition = CGPointMake(spider.position.x,
-10);
CCMoveTo* move = [CCMoveTo actionWithDuration:spiderMoveDuration position:belowScreenPosition];
CCActionEase*esay=[CCEaseExponentialOut actionWithAction:move];
CCCallFuncN* callDidDrop =[CCCallFuncN actionWithTarget:self selector:@selector(spiderDidDrop:)];
CCSequence* sequence = [CCSequence actions:esay, callDidDrop, nil];
if ([spider runAction:sequence])
{
currentScore++;
}
}
-(void) level5:(CCSprite *)spider
{ numSpidersMoved++;
ccTime delayTime=2.5f;
if (numSpidersMoved %8 == 0 && delayTime>1.0f)
{
delayTime-=0.2f;
}
CGPoint dropALittleBit= CGPointMake(spider.position.x, 350);
CGPoint belowScreenPosition= CGPointMake(spider.position.x, -10);
CCMoveTo*move =[CCMoveTo actionWithDuration:0.8 position:dropALittleBit];
CCDelayTime*delay=[CCDelayTime actionWithDuration:delayTime];
CCMoveTo*drop=[CCMoveTo actionWithDuration:0.3f position:belowScreenPosition];
CCCallFuncN*callDidDrop=[CCCallFuncN actionWithTarget:self selector:@selector(spiderDidDrop:)];
if ([spider runAction:[CCSequence actions:move,delay,drop,callDidDrop, nil]])
{
currentScore++;
}
}
-(void) spiderDidDrop:(id)sender {
// Make sure sender is actually of the right class.
NSAssert([sender isKindOfClass:[CCSprite class]], @"sender is not a CCSprite!");
CCSprite* spider = (CCSprite*)sender;
// move the spider back up outside the top of the screen
CGPoint pos = spider.position;
CGSize screenSize = [[CCDirector sharedDirector] winSize];
pos.y = screenSize.height + [spider texture].contentSize.height;
spider.position = pos;
}
参照だけに「' texture'」あなたは 'spiderDidDropに' pos.y'を割り当てるしようとしているところ私がそこにあるアップダンプという巨大な大規模なソースコードで参照することができます願っています。例外がスローされている場所ですか? –
sry guys私は敵とプレイヤーのサイズを計算するためにテクスチャを使用しています。私が尋ねたいのは、 "level1:"メソッドだけを使用するときに問題はないが、他のメソッドを使用すると、他のレベルのメソッドを単独で使用してもそのエラーが発生するということです。 – user1292919