-
Using Random
using Random
hi i need to use the random for set the position for a sprite
this is my code if anyone knows plz help me
here is my code
x_enemySprite[0] = new Sprite(Image.createImage("/E4.png"));
x_enemySprite[0].setPosition(0,27);
x_enemyXSpeed[0] = -2;
x_enemySprite[1] = new Sprite(Image.createImage("/E5.png"));
x_enemySprite[1].setPosition(52,10);
x_enemyXSpeed[1] = -2;
x_enemySprite[2] = new Sprite(Image.createImage("/E6.png"));
x_enemySprite[2].setPosition(30,20);
x_enemyXSpeed[2] = -2;
-
Where in your code do you want it? what kind of random number? Is it in a range ie between 500 & 900?
Have you read the API doc for the Random class?