У меня сейчас проблемы с игрой, она продолжает падать, когда я слишком сильно ее подчеркиваю. Это означает, что я безумно скользил, шевелил или стучал пальцами по экрану, и он падал. Крушение не имеет правил. Я попытался обнаружить, в журнале консоли отображается сообщение о нехватке памяти. Я знаю, что речь идет о памяти, но я использую Cocos2D, чтобы сделать эту игру, я следовал инструкциям в лучшей практике. После этого он кажется более плавным, но все равно падает, если мне нравится то, что я упомянул выше. Если как в Какао, у нас есть alloc и release, но это Cocos2D, я думаю, нам не нужно этого делать. Моя игра просто загружает изображения и делает анимацию после касания.
//where the fingers ended , this will determine the correct actions made.
-(BOOL)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent *)events
{
int touchCount = 0;
NSSet *allTouches3 = [events allTouches];
for( UITouch *touch in allTouches3)
{
location3 = [touch locationInView: [touch view]];
location3 = [[Director sharedDirector] convertCoordinate: location3];
NSLog(@"end TOUCHed x2: %3.3f, y2: %3.3f",location3.x,location3.y);
touchCount++;
}
[self removeChildByTag:kTagWord cleanup:YES];
timeEnd = [NSDate timeIntervalSinceReferenceDate];
touchDuration = timeEnd - timeStart;
//float rangeX = location3.x - location.x;
rangeY2 = location3.y - location.y;
//loading the succesful opened box with 2 touches same direction
if ((touchCount > 0 && touchCount ==2) && (rangeY2 > 0.0 && rangeY2 <15.0))
{
box++;
self.isTouchEnabled = NO;
[self removeErrorText];
if (box == 1)
{
[self loadingTheRest];
}
else if (box == 2)
{
[self loadingTheRest1];
}
else if (box ==3)
{
[self loadingTheRest2];
}
if (currentBox == 0 )
{
[self addText];
[self boxOpenAnimation];
[self schedule:@selector(enableTheTouches) interval:1.0f];
} else if(currentBox == 1 )
{
[self addText1];
[self boxOpenAnimationPink];
//[self schedule:@selector(winGame) interval:0.4f];
[self schedule:@selector(enableTheTouches) interval:1.0f];
}
}
}
и это пример загрузочной коробки
-(void)loadingTheRest
{
//LOADING OTHER COLOURS
AtlasSpriteManager *managerPink = [AtlasSpriteManager spriteManagerWithFile:@"PinkNew.png"];
AtlasSpriteManager *error2 = [AtlasSpriteManager spriteManagerWithFile:@"PinkErrors.png"];
[self addChild:managerPink z:1 tag:kTagSpriteManagerPink ];
[self addChild:error2 z:1 tag:kTagSpriteErrorPink ];
}
-(void)boxOpenAnimation
{
if (isBusy==YES)
{
return;
}
isBusy=YES;
[self removeBoxColours];
AtlasSpriteManager *mrg = (AtlasSpriteManager *)[self getChildByTag:kTagSpriteManager];
AtlasSprite *box = [AtlasSprite spriteWithRect:CGRectMake(482, 322,480, 320) spriteManager:mrg];
box.position = ccp(240,160);
[mrg addChild:bra z:1 tag:1984];
AtlasAnimation *animation = [AtlasAnimation animationWithName:@"open" delay:0.1];
[animation addFrameWithRect: CGRectMake(1, 322, 480, 320) ];
[animation addFrameWithRect:CGRectMake(482, 1, 480, 320)];
[animation addFrameWithRect:CGRectMake(1, 1, 480, 320)];
[animation addFrameWithRect:CGRectMake(1, 643, 480, 320)];
id action = [Animate actionWithAnimation:animation];
[box runAction:action];
[self loadingTheRest];
isBusy=NO;
}
Пожалуйста, поделитесь своими знаниями со мной, если вы знаете о причинах сбоя моей игры.
Большое вам спасибо