Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/120.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我的应用程序中出现NSInvalidArgumentException错误。。。有谁擅长这个,请帮帮我_Ios_Cocos2d Iphone_Objective C 2.0 - Fatal编程技术网

Ios 我的应用程序中出现NSInvalidArgumentException错误。。。有谁擅长这个,请帮帮我

Ios 我的应用程序中出现NSInvalidArgumentException错误。。。有谁擅长这个,请帮帮我,ios,cocos2d-iphone,objective-c-2.0,Ios,Cocos2d Iphone,Objective C 2.0,我试图在我的游戏中添加不同的关卡。当玩游戏时,分数会上升并达到一定的分数,然后等级会改变。这是我的计划,但我编写了一个类似“spiderupdate:(cctime)delta”的代码,如您所见,其中包含if代码。我很确定这就是问题所在,当我不把“如果”放在那里,只使用一个关卡时,它不会崩溃。 有谁能帮我弄清楚怎么修吗 错误类似于“NSInvalidArgumentException”,原因:“-[Play texture]:未识别的选择器发送到实例0xf57da10” Play是我的类名,纹理

我试图在我的游戏中添加不同的关卡。当玩游戏时,分数会上升并达到一定的分数,然后等级会改变。这是我的计划,但我编写了一个类似“spiderupdate:(cctime)delta”的代码,如您所见,其中包含if代码。我很确定这就是问题所在,当我不把“如果”放在那里,只使用一个关卡时,它不会崩溃。 有谁能帮我弄清楚怎么修吗

错误类似于“NSInvalidArgumentException”,原因:“-[Play texture]:未识别的选择器发送到实例0xf57da10”

Play是我的类名,纹理应该是方法,但我没有任何名为texture的方法

-(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;
}
-(无效)spidersUpdate:(ccTime)delta{
//尝试查找当前未移动的蜘蛛。
对于(int i=0;i<10;i++)
{
int randomSpiderIndex=CCRANDOM_0_1()*[spider count];
CCSprite*spider=[spiders objectAtIndex:randomSpiderIndex];
//如果爬行器不移动,它将不会有任何运行操作。
如果([spider numberOfRunningActions]==0)
{   
如果(currentScore这里有一个链接
告诉CCCsprite的属性,您可以看到并没有作为纹理的属性,所以如果您想要,请检查并使用TextureBu立属性


希望它能帮助

唯一参考“
纹理
”我从大量的源代码转储中看到,您试图在
spiderDidDrop:
方法中分配
pos.y
。这就是引发异常的地方吗?各位,我正在使用纹理计算敌人和玩家的大小。我想问的是,当我只使用“level1:”时没有问题方法,但如果我使用其他方法,即使我单独使用其他级别的方法,也会带来错误。