[SOLVED] Create texture on fly

[SOLVED] Create texture on fly
0.0 0


Hi, Searched forums but have not found what I need.

What I want to do is create a texture on the fly to use as a sprite. I have a background image and in set position over that background image I will be placing sprites. There could be 100’s of sprites. Basically what would be quicker (for frame rate reasons ) is to load background. Create new texture form this and each time a new sprite is added to that background then physically draw it on the background image. Like I said the sprites are static so will never move which means drawing them into the actual background sprite means that I only ever draw that one background sprite each frame.



OK figured this out

    var rend = new cc.RenderTexture();
    rend.initWithWidthAndHeight(1118, 800, cc.IMAGE_FORMAT_PNG, 0);


Well, that looks interesting.

Are you calling this every frame? Or how are you using it?


I create this at the start. Basically the rend becomes my sprite.

If you have multiple sprites on screen which never change position it saves so much time to build up a sprite with your background and then write the sprites into it. IN effect you end up with just one sprite to display :slight_smile: