Wednesday, April 6, 2011

Dynamically create sprite images for Cocos2d-iPhone

Hey guys,

I'm working on a platformer, and looking for a way to create a sprite for an arbitrarily sized platform. For example, I may know I have a platform that should appear 200 pixels wide by 32 pixels high, and, say, I have a texture of bricks that I can tile to fill that area. I may also want to draw a black border around the platform. Is this possible at all? Anyone have any ideas for how I might go about doing this? I could always try generating the image on the fly and building a sprite with that image, but I sincerely doubt (hope) that this isn't the most efficient way of doing something like this.

Cheers, Alex

From stackoverflow
  • You can use tiled maps for the platform. It will require you to plan your textures a bit differently, but it will probably yield better results.

    You can read more about tiled maps here.

    AlexC : Thanks, I guess this is probably going to be my best bet. It's a shame that there isn't any more flexible way to draw custom sprites. Still, I haven't contributed to the code so who am I to complain :)
    matt : This is the way these things have been done in games, since forever. ;)

0 comments:

Post a Comment