Question

I know this has to be possible, and I'm just not finding it. Is there a way to just create a sprite with AndEngine, and just draw to it IE create a bit map texture that is not loaded from a sprite file? IE create a rectangle and color it blue?

Something like the following under IOS:

SKSpriteNode sn = [SKSpriteNode spriteNodeWithColor:Color.Red size:CGSizeMake(30, 30)];

All the examples I am finding center around loading a graphic image, and I am just looking to create some rectagles.. Sure I could make Images of the size I want but that seems a bit silly... There has to be a way to create a texture of a size and color it and then just load it to Sprite.. no?

Was it helpful?

Solution

You can create rectangles at will using something like

private Rectangle board;

board = new Rectangle(x, y, width, height, this.getVertexBufferObjectManager());
board.setAlpha(0.0f);
board.setColor(0.04804f, 0.6274f, 0.4784f);
scene.attachChild(board);

You may or may not need to set the Alpha - this is just an excerpt from my code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top