Skip to content Skip to sidebar Skip to footer

Cocos2d Android Texture Issue On Motorola Xoom

I am developing a game in android with Cocos2d framework with latest build from github(Weikuan Zhou). In my game, I used lots of images(total images size is around 11MB). Problem:

Solution 1:

From what you're describing, you're hitting exactly the same problem i did, which is that cocos2d for android is really buggy when dealing with lots of single sprites loaded individually.

The best route to take to resolve this problem is to get hold of (unless you've got a mac) the free flash version of zwoptex from here http://zwopple.com/zwoptex/static/downloads/zwoptex-flashversion.zip

this will let you build up spritesheets, i suggest relating as many sprites as you can onto each sheet, whilst trying to keep them sensibly grouped.

This is mainly down to cocos doing a single render for ALL sprites in a spritesheet, rather than one render per sprite for normal sprites, hence massively reduced processing time, and much less memory usage.

you can then load the spritesheet with code such as (can't guarantee this code will execute as i'm grabbing snippets from a structured project but it will lead you to the right solution)

CCSpriteFrameCache.sharedSpriteFrameCache().addSpriteFrames("menus.plist");  // loads the spritesheet into the frame cacheCCSpriteSheetmenuSpriteSheet= CCSpriteSheet.spriteSheet("menus.png", 20); // loads the spritesheet from the cache ready for use

.... // menu is a CCLayerCCSpritesprite= CCSprite.sprite(CCSpriteFrameCache.sharedSpriteFrameCache().spriteFrameByName("name of sprite from inside spritesheet.png"));

menuSpriteSheet.addChild(sprite, 1, 1); /  you add the sprite to its spritesheet
menu.addChild(menuSpriteSheet, 1);  // then add the spritesheet to the layer

Solution 2:

This problem happens when you load resources at run time. So it is better to load resources before the scene starts.You can do as follows.

  1. Using the sprite sheets for resources in your game.
  2. Implement your Ui in constructor of your class.
  3. Implement your functionality in overridden method onEnter() in your layer.
  4. You must unload your sprite sheets after finishing your scene.

These is the procedure that I am following. Thanks.

Post a Comment for "Cocos2d Android Texture Issue On Motorola Xoom"