now my situation is this , i have a sprite , the sprite need to do two kind of animation, i use two png file for this (i cannot put them in one , 'cause the iPhone4's texture is limited to 2048x2048), now because there will be many sprites to add to layer , so i use CCSpriteBatchNode , but CCSpriteBatchNode only support one texture inside it .please help..thanks in advance.
how can i use two textures in one CCSpriteBatchNode???
(13 posts) (5 voices)-
Posted 5 months ago #
-
You can't use two textures in one CCSpriteBatchNode. CCSpriteBatchNode exists to batch the drawing of sprites with the same texture into a single draw call.
Posted 5 months ago # -
in my case, how can i do to be more efficient?
Posted 5 months ago # -
More efficient than what? Are you running into performance problems? Or are you trying to optimize to get ahead of the curve?
Posted 5 months ago # -
well , i mean that in the same layer my sprite would use two animations , we know that one animation will use a big sprite sheet(i can not put two sprite sheet as one , because iphone4 is limited to 2048 x 2048). so if i don't use CCSpritebatchnode , i can add my sprites into one layer, but the problem is i have tens of sprite to add. if i want to use CCSpritebatchnode , how can i do .
)Posted 5 months ago # -
Reduce the number of frames in your animation so you can fit both onto one texture or make your game first and see if you even need a batchnode to achieve the performance you desire.
Either way a batchnode is tied to a single texture.
Posted 5 months ago # -
thainks for reply, i cannot reduce them to make one texture. i have different sprites which will use different textures.
Posted 5 months ago # -
How about creating multiple CCSpriteBatchNodes? Does the main character use ALL the frames, or are some of the frames for the character and other frames for the enemies? It's perfectly fine to have multiple batch nodes active at once. Maybe you could have one batch node for the main character, another batch node for the background and another batch node for the enemies? That will still be more efficient than not using any batch nodes.
I use this approach in my Rugby game and the frame rate stays really high.
Posted 5 months ago # -
If you create multiple batch nodes, you can use vertex z on the sprites so that they are drawn independent of their parent's (the batch node) z-order.
Posted 5 months ago # -
thank you guys, i will try using different bathnode for one sprite at the same time!
Posted 5 months ago # -
@nosywombat , by the way, dose your Rugby game have upload to APPSTORE? i would really to take a look , thank you !
Posted 5 months ago # -
Shameless plug - @AndyCai, here is the App Store link:
https://itunes.apple.com/au/app/drew-mitchells-runnin-rugby/id454706193?mt=8
Posted 5 months ago # -
woo, really cool app!
Posted 5 months ago #
Reply
You must log in to post.