ios


game crashes with SIGKILL when running animation on custom SKSpriteNode


I'm encountering a very weird error causing my app to crash. I have created a custom SKSpriteNode called heroSpriteNode. Here is my initialization:
(id) init
{
if (self = [super init])
{
[self loadAnimations];
SKTexture *temp = self.gorillaStandingFrames[0];
self = [heroSpriteNode spriteNodeWithTexture:temp];
[self setUpHeroDetails];
}
return self;
}
The error is occurring when attempting to run an action on "self" the custom SkSpriteNode, like this:
-(void)jump
{
NSLog(#"Jump Tap!");
if(self.isOnTheGround)
{
self.physicsBody.velocity = CGVectorMake(0, 0);
self.physicsBody.angularVelocity = 0;
self.timedJump=NO;
[self.physicsBody applyImpulse:CGVectorMake(0, 350)];
[self removeActionForKey:#"walkingInPlaceBear"];
[self jumpingGorilla2]; // HERE IS THE ERROR
self.isOnTheGround=NO;
self.isRunning=NO;
self.isStanding=NO;
self.jumpFixTimer = [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:#selector(flipTimedJumpBoolean) userInfo:nil repeats:NO];
}
}
I know this animation (and other animations I run) is the issue, because when I comment out that line the game runs fine.
Here is how I am loading the textures and creating an action:
-(void)loadJumpAnimation2
{
NSMutableArray *jumpFrames = [NSMutableArray array];
SKTextureAtlas *gorillaAnimatedAtlas = [SKTextureAtlas atlasNamed:#"mainCharJump"];
int numImages = gorillaAnimatedAtlas.textureNames.count;
for (int i=2; i <= numImages; i++) {
NSString *textureName = [NSString stringWithFormat:#"j%d", i];
SKTexture *temp = [gorillaAnimatedAtlas textureNamed:textureName];
[jumpFrames addObject:temp];
}
self.gorillaFlyingJump = jumpFrames;
}
-(void)jumpingGorilla2
{
[self runAction:[SKAction repeatActionForever:
[SKAction animateWithTextures:self.gorillaFlyingJump
timePerFrame:0.25f
resize:NO
restore:YES]] withKey:#"jump"];
return;
}
When it crashes there is no crash report in the logger, only a popup message in Xcode that is of type: 9 SIGKILL. It seems like this could be a memory issue related to how the animation frames are being stored? The animations ran fine on a standard SkSpriteNode, then after refactoring much of the code into a custom SkSpriteNode, I can no longer apply animations. Any ideas? Thank you.
UPDATE:
I've created another class to try to isolate the issue I'm having, I will post the code below with comments.
Here is the entire test class I created:
#import "heroTestNode.h"
#implementation heroTestNode
- (id) init
{
if (self = [super init])
{
[self loadAnimations];
SKTexture *temp = self.gorillaWalkingFrames[0];
self = [heroTestNode spriteNodeWithTexture:temp];
}
return self;
}
-(void)loadAnimations
{
NSMutableArray *walkFrames = [NSMutableArray array];
SKTextureAtlas *gorillaAnimatedAtlas = [SKTextureAtlas atlasNamed:#"mainCharRun2"];
int numImages = gorillaAnimatedAtlas.textureNames.count;
NSLog(#"Here are how many animation frames: %d", numImages);
for (int i=1; i <= numImages; i++) {
NSString *textureName = [NSString stringWithFormat:#"r%d", i];
SKTexture *temp = [gorillaAnimatedAtlas textureNamed:textureName];
[walkFrames addObject:temp];
}
self.gorillaWalkingFrames = walkFrames;
}
-(void)walkingGorilla // running this is causing the SIGKILL 9 crash
{
[self runAction:[SKAction repeatActionForever:
[SKAction animateWithTextures:self.gorillaWalkingFrames
timePerFrame:0.1
resize:NO
restore:YES]] withKey:#"test"];
return;
}
#end
Here is the interface:
#import <SpriteKit/SpriteKit.h>
#interface heroTestNode : SKSpriteNode
#property NSMutableArray *gorillaWalkingFrames;
-(void)walkingGorilla;
#end
And finally, here is how I am instantiating it:
heroTestNode *test = [[heroTestNode alloc] init];
test.position = CGPointMake((self.frame.size.width/2)+30,self.frame.size.height/3);
[self addChild:test];
[test walkingGorilla]; // this is causing the SIGKILL 9 crash
This causes the it to freeze "compressing" the view into the bottom left corner of my iPad and going unresponsive. I have no idea what would be causing this.

Related Links

How to prevent NSInternalInconsistencyException with Realm and UICollectionView
(Swift, EarlGrey) move slider to the middle
How can I make physicBody dynamic only on needed levels?
check if item exists in core data EFFICIENTLY
How to continue in the background a connection started with NSURLConnection in the foreground?
Using delegate methods to save a custom cell textfield
Move a UILabel when changing to landscape
“show” segue inside UITabBarController & UINavigationController does not push
Deep linking in iOS 10 not working
Command /bin/sh failed with exit code 133 - CocoaPods error macOS Sierra
Bluetooth LE on iOS10 strange behavior
add handle to uiScrollView like in the screenshot
Xcode unexpectedly quit while reopening windows every time
How to set up UIBezierPath border for view in ios?
Trying to parse JSON in Swift, but get error
Crashlytics does not show crashes

Categories

HOME
flutter
ffmpeg
applet
design
chronicle
ionic3
spi
whitespace
cross-domain
wso2-das
w3.css
openmodelica
openui5
graph-tool
vscode-settings
avr
records
vast
zap
robotium
yii1.x
solarwindslem
udid
sqlite.swift
apex-code
gosublime
aem-6
pdfstamper
spring-data-cassandra
msal
jetty-9
amazon-elasticsearch
es6-promise
subscription
using
freerdp
karnaugh-map
ase
log4perl
scoring
python-module
bosh-deployer
facebook-audience-network
menustrip
selenium2library
sliding
xlform
asp.net-webpages
id3
skrollr
multiple-files
membership
thinktecture-ident-server
interpreted-language
gulp-rename
viennacl
ppl
google-swiffy
lossless-compression
mks
simpleadapter
django-postgresql
android-menu
aps
custom-titlebar
twill
data-quality
b2b
yourls
validform
re2c
adlds
arbtt
godaddy-api
12factor
squirrelmail
makumba
lungojs
rpn
android-actionmode
vim-fugitive
blackberry-os-v5
android-3.1
system-tray
winamp
executescalar
scramble
webshop
xml-database
gumstix
clipboard-pictures

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App