Skip to main content

Posts

Showing posts with the label cocos2d

scaling ccdirector cocos2d

I'm making a pixel art app and the resolution is 320x240. I want to scale some how ccdirector or eaglview to fit full device screen. I tried setContentScaleFactor in ccdirector and eaglview or else eagllayer, but it appears work differently in those cases, and didn't get what I want in any. What is the correct way to do that? Currently I'm scaling the CCScene, but when some sprite isn't in integer number, they stay in the middle of pixel grid, what is not correct.

CCTMXTiledMap propertiesForGID:(CGPoint)

i m working in cocos2d 0.99.0 my project have a file with name CCTMXTiledMap.h & .m but there is no public method with name propertiesForGID:(CGPoint) so please if u have this method in your cocos2d then please send me code of this method which i can use in .h and .m file. thanx.

Cocos2D iPhone - running actions on multiple targets + callback

I have an array of objects (objArray) and an array of actions (actArray). Both arrays are in order, I mean, object at index 0 of objArray has to perform action 0 on actArray. To make the explanation clear, lets imagine both arrays have 3 objects, obj0, obj1 and obj2. obj0 has to perform action 0 on actArray obj1 has to perform action 1 on actArray obj2 has to perform action 2 on actArray these 3 operations (or n, in the case of the array) have to happen simultaneously. When all animations end, I need the method animationsFinished to be called. How do I do that? I am beginning in Cocos. I have googled around and have not found any practical example around. I have found CCSpan but I don't see how this can be used with multiple objects each one with its own action. thanks.

Cocos2D iPhone - will this save memory?

When you create a sprite on cocos using a texture you allocate memory. Something like: CCTexture2D *textureProxy = [[CCTexture2D alloc] initWithImage:image]; CCSprite *proxy1 = [CCSprite spriteWithTexture:textureProxy]; My question is: suppose I want several sprites using the same texture and I do CCSprite *proxy1 = [CCSprite spriteWithTexture:textureProxy]; CCSprite *proxy2 = [CCSprite spriteWithTexture:textureProxy]; CCSprite *proxy3 = [CCSprite spriteWithTexture:textureProxy]; CCSprite *proxy4 = [CCSprite spriteWithTexture:textureProxy]; CCSprite *proxy5 = [CCSprite spriteWithTexture:textureProxy]; Will I use 5 times more memory? (or in other words, will the texture be duplicated to each proxy or is the sprite just a "empty box" that references the original texture? If the later is the answer, then the memory usage for similar sprites are not that huge, right? thanks.

""CCLayer" may not respond to … ”

Playing with cocos2d and this seems to come up in some instances of message passing. I have to admit, I'm not well versed in Objective-C yet as I'm reading through the book as I write some code. For people familiar with cocos2d, you have a CCLayer class. In my case, I have a GameLayer which has some children layers, like so: @interface GameLayer : CCLayer { CCSprite *_background; CCPanZoomController *_controller; CCLayer *_truckLayer; } I then have a special initWithLayers method to add my child layers within this layer: -(id)initWithLayers:(TruckLayer *)truck { if( (self=[super init])) { self.truckLayer = truck; ..... } Now if I ever send a message to self.truckLayer I get the following warning in Xcode: 'CCLayer' may not respond to 'getNextAvailableSpot' An example might be doing something like so: CGPoint nextSpot = [self.truckLayer getNextAvailbleSpot]; All this code compiles and runs successfully, so I'm curious as to w