I am new in AndEngine. I am using following code to display an image of a ball.
private ITextureRegion mBallTextureRegion;
private Sprite ball1;
@Override
public void onCreateResources() {
ITexture ball = new BitmapTexture(this.getTextureManager(),
new IInputStreamOpener() {
@Override
public InputStream open() throws IOException {
return getAssets().open("gfx/ball.png");
}
});
this.mBallTextureRegion = TextureRegionFactory.extractFromTexture(ring1);
....................
....................
}
@Override
protected Scene onCreateScene() {
final Scene scene = new Scene();
scene.attachChild(backgroundSprite);
...........
ball1 = new Sprite(192, 63, this.mBallTextureRegion, getVertexBufferObjectManager());
scene.attachChild(ball1);
..............
...........
}
Now, depending on the game level I want to add multiple ball of different size in the scene. Is it possible to add ITextureRegion mBallTextureRegion multiple time in different size(using different magnifying it)? If it is, then how? Please help me this sample code.
if you want to resize a Sprite,AnimatedSprite,Text,etc…
if you use a texture region in more sprites:
and if you want generate random position of each ball use “Random” variable.
best regards.