Prior to Coco2D, my app's sky was a simple vertex gradient. Given that the sky is 5000 pixels in height, I don't want to use a textured Sprite.
Any recommendations?
A fast, easy to use, free, and community supported 2D game engine
Prior to Coco2D, my app's sky was a simple vertex gradient. Given that the sky is 5000 pixels in height, I don't want to use a textured Sprite.
Any recommendations?
You can create your own. Make a GradientLayer based on the ColorLayer. Its just rendering a quad, so have it do a quad with color at each vert. You can then do a gradient since it'll blend between them.
would a gradient layer be faster than a texture?
-zombie
Thanks nsxdavid. ColorLayer doesn't allow specification of each vertice's color. I simply extended CocosNode and wrote my own per-vertex color rendering.
Hi Zombie. For my 5000 pixel gradient, the memory footprint is too large to consider using textures.
Ok, thats pretty understandable :)
But would a gradient be faster than a 320x480 texture?
-zombie
Yes, drawing an untextured quad should be significantly faster than a textured quad, since you don't have to lookup any pixel data..
Hi,
I'm trying to do the same thing, but I'm having trouble w/ the gradient layer when transitioning between scenes. The gradient layer won't fade out, it just all of a sudden disappears after the rest of the scene is done fading out.
Basically as a test I hardcoded the updateColor method in CCLayer.m to have squareColors use a gradient instead of a solid color.
@biospher Did you see this with your custom gradient code too?
Any help would be much appreciated, thanks!
-Taber
Oops, nevermind! In case it helps anyone else... Like I said, I was testing my gradient code inside CCLayer.m but the problem is CCCrossFadeTransition uses an invisible instance of CCLayer to do its fading. So, after sublassing CCNode, transitioning the gradient worked just fine.
Would anybody mind posting some sample code to help me get started? I've poked around a bit, but can't quite make sense of the squareVerticies/squareColors in CCColorLayer. Thanks!
You must log in to post.