0

I am writing a game in cocos2d v3 which has platforms whose shapes can be manipulated by the user. I know every point along the edge of the platform, and want to render a texture just within the shape of the platform so it will appear solid. I know I need to use OpenGl, or a CCrender texture, but I am a complete beginner to it and can only articulate my ideas in words, not in code. I don't know if any of these would work. Please help me by giving an example of what I should do. Here are my ideas:

[1] - To color the shape white, and put a ccrednertexture under it and render the texture to the render texture - then use a blend function to only allow what is under the white on the render texture to show through.

[2] To use the vertexes around the shape to do something like this:

CCRenderBuffer buffer = [renderer enqueueTriangles:2 andVertexes:4 withState:_lightRenderState globalSortOrder:0];
                CCRenderBufferSetVertex(buffer, 0, LightVertex(projection, GLKVector2Make(pos.x - radius, pos.y - radius), GLKVector2Make(0, 0), color4));
                CCRenderBufferSetVertex(buffer, 1, LightVertex(projection, GLKVector2Make(pos.x - radius, pos.y + radius), GLKVector2Make(0, 1), color4));
                CCRenderBufferSetVertex(buffer, 2, LightVertex(projection, GLKVector2Make(pos.x + radius, pos.y + radius), GLKVector2Make(1, 1), color4));
                CCRenderBufferSetVertex(buffer, 3, LightVertex(projection, GLKVector2Make(pos.x + radius, pos.y - radius), GLKVector2Make(1, 0), color4));
                CCRenderBufferSetTriangle(buffer, 0, 0, 1, 2);
                CCRenderBufferSetTriangle(buffer, 1, 0, 2, 3);
genpfault
  • 51,148
  • 11
  • 85
  • 139
theideasmith
  • 2,835
  • 2
  • 13
  • 20
  • Are you simply talking about allowing users to color over the platforms? – Allen S Aug 07 '14 at 14:12
  • No, they can reshape it by dragging around its vertexes, and I want to render a texture inside the shape created by the different vertexes. – theideasmith Aug 07 '14 at 22:17

0 Answers0