I’m working on an iPhone app in objective-c also using cocos2d for graphics. I have a large sprite and I have done research on how to scale the sprite and my code looks like this…
//Set up sprite
// Use batch node. Faster
CCSpriteBatchNode *parent = [CCSpriteBatchNode batchNodeWithFile:@"egg.png" capacity:100];
eggTexture_ = [parent texture];
[eggTexture_ setScaleX: 10/eggTexture_.contentSize.width];
[eggTexture_ setScaleY: 10/eggTexture_.contentSize.height];
And it compiles fine! Then I get a run time error “SIGABRT”. I can’t find the problem. It’s probably something amature. Looking back there are “warnings” after those last to lines that reads “CCTexture2d may not respond to setScaleX”. Any help is much appreciated 🙂 thankyou
Actually, the class CCTexture2D does not respond to setScaleX and setScaleY. The object picked by the statement [parent texture] is a texture, thus you must be getting an error message similar to this
* Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘-[CCTexture2D setScaleX:]: unrecognized selector sent to instance 0x5e14c70’
I am not certain why you would want to scale the texture, i suspect you would rather scale a CCSprite, and place that in your scene. like :
etc …