// init constructor public Enemy(Bitmap res, int width, int height, int numFrames) { spritesheet = res; x = (GamePanel.screenWidth / 2) - (width / 2); y = (GamePanel.screenHeight / 2) - (height / 2); Bitmap[] image = new Bitmap[numFrames]; // creates the sprite frames for animations for (int i = 0; i < numFrames; i++) { // System.out.println("W: " + i * width + " H: " + height); image[i] = Bitmap.createBitmap(spritesheet, i * width, 0, width, height); } // sets frames and delay between frames animation.setFrames(image); animation.setDelay(60); }
public Fly(Bitmap res) { // Spawning in random x axis, from a number from 0 - 336! int randomNum = (int) Math.ceil(Math.random() * 336); x = randomNum; // Spawning outside the screen! y = -32; height = 32; width = 48; // Array to sort out the different sprites Bitmap[] image = new Bitmap[3]; for (int i = 0; i < image.length; i++) { image[i] = Bitmap.createBitmap(res, i * width, 0, width, height); } animation.setFrames(image); animation.setDelay(2); }