andEngine dynamic sprites
Posted
by
Blucreation
on Game Development
See other posts from Game Development
or by Blucreation
Published on 2012-02-26T15:07:55Z
Indexed on
2012/09/20
15:52 UTC
Read the original article
Hit count: 272
andengine
Ive just started with andEngine the past week and i only started learning java/android 3 weeks.
I can use a for loop to add multiple sprites to the screen but when i try to check collisions on them it only does it to one and not the rest.
I want to be able to add a specific number for sprites made from the same texture to the scene, add collision detection to them and also make them slide across the screen (im making a game where you avoid the obstacles).
My simple code:
private void createobstacle(float pX, float pY) {
obstacle = new AnimatedSprite(pX, pY, this.mObjTextureRegion.deepCopy(), getVertexBufferObjectManager());
obstacle.setScale(MathUtils.random(0.5f, 3f));
scene.attachChild(obstacle);
}
private void createobstacle(int num) {
for(int i=0; i<=num; i++ ) {
final float xPos = MathUtils.random(30.0f, (CAMERA_WIDTH - 30.0f));
final float yPos = MathUtils.random(30.0f, (CAMERA_HEIGHT - 30.0f));
createobstacle(xPos, yPos);
}
}
Ive read about arrays but i cannot find any tutorials about anything im stuck with.
Any help would be great!
© Game Development or respective owner