Tell me this question: Packed the textures, connected the atlas and actually initialized the images, but by clicking on the old, the application crashes with an error: on a null object reference and swears at this line game.batch.draw (sprite, raindrop.x, raindrop.y );
r1 = new Sprite(atlas.findRegion("r1")); r2 = new Sprite(atlas.findRegion("r2")); r5 = new Sprite(atlas.findRegion("r5")); r10 = new Sprite(atlas.findRegion("r10")); r20 = new Sprite(atlas.findRegion("r20")); r50 = new Sprite(atlas.findRegion("r50")); r100 = new Sprite(atlas.findRegion("r100")); r200 = new Sprite(atlas.findRegion("r200")); r500 = new Sprite(atlas.findRegion("r500")); k1 = new Sprite(atlas.findRegion("k1")); k2 = new Sprite(atlas.findRegion("k2")); k5 = new Sprite(atlas.findRegion("k5")); k10 = new Sprite(atlas.findRegion("k10")); k20 = new Sprite(atlas.findRegion("k20")); k50 = new Sprite(atlas.findRegion("k50")); Sprite bucketImage, r1, r2, r5, r10, r20, r50, r100, r200, r500, k1, k2, k5, k10, k20, k50; It is necessary to create an array of Sprite of these images, and then draw on the screen like this:
game.batch.draw(bucketImage, bucket.x, bucket.y); for (Rectangle raindrop : raindrops) { for (Sprite sprite : sprites) { game.batch.draw(sprite, raindrop.x, raindrop.y); } } private void spawnRaindrop() { Rectangle raindrop = new Rectangle(); raindrop.x = MathUtils.random(0, 800 - 64); raindrop.y = 480; raindrop.width = 64; raindrop.height = 64; raindrops.add(raindrop); lastDropTime = TimeUtils.nanoTime(); } game.batch.end(); spawnRaindrop () creates a new Rectangle, sets it in a random position at the top of the screen and adds it to the raindrops array.