assets/ directory in the project root.
Asset Directory Structure
Images
Player Character
Used for: Player-controlled birdLoaded at:
SpaceEscape.java:148Display size: 64x64 pixelsDescription: The main Angry Birds character (red bird) that the player controls. This serves as the “spaceship” in the space shooter theme.Hitbox: 75% of visual size (48x48 pixels) for fair collision detection (Player.java:52-56)Obstacles
Used for: Enemy obstaclesLoaded at:
SpaceEscape.java:152Display size: 62x48 pixelsDescription: Pig characters from Angry Birds that serve as enemies falling from the top of the screen.Hitbox: 75% of visual size (46.5x36 pixels) for fair collision detection (Obstacle.java:46-50)Spawn rate: Every 0.5 seconds during gameplay (SpaceEscape.java:297)Projectiles
Used for: Player bulletsLoaded at:
SpaceEscape.java:154 and Player.java:60Display size: 10x20 pixelsDescription: Red projectiles fired by the player to destroy pig obstacles.Speed: 10 pixels per frame upward (Player.java:110)Cooldown: 0.3 seconds between shots (Player.java:62)Backgrounds
noche.jpg
Context: Game background (PLAYING state)Loaded at:
SpaceEscape.java:140Usage: Rendered at full screen size behind all game objects (SpaceEscape.java:392)Theme: Night sky/space theme for the shooter gameplayspace.jpg
Context: Menu background (MENU state)Loaded at:
SpaceEscape.java:142Usage: Rendered at full screen size on the main menu (SpaceEscape.java:384)Theme: Space-themed logo or title screenMusic
Background music loops continuously based on game state.Menu Music
Context: Main menu background musicLoaded at: Playback:
SpaceEscape.java:155-157Configuration:- Starts when entering MENU state
- Pauses when starting gameplay
- Resumes when returning to menu from GAME_OVER
Gameplay Music
Context: Active gameplay background musicLoaded at: Playback:
SpaceEscape.java:158-160Configuration:- Starts when entering PLAYING state
- Pauses when viewing score screen
- Stops when entering GAME_OVER state
Sound Effects
Sound effects are played as one-off sounds (not looped).Shoot Sound
Trigger: Player fires a bulletLoaded at:
Player.java:59Played at: Player.java:116Volume: 50% (0.5f)Description: Classic shooting sound effect played when the player presses SPACE or right-clicks to shoot.Explosion Sound
Trigger: Bullet hits pig obstacleLoaded at:
SpaceEscape.java:161Played at: SpaceEscape.java:340Volume: 70% (0.7f)Description: Pig death sound from Angry Birds, played when a bullet successfully destroys an obstacle.Engine Sound
Trigger: Game starts (entering PLAYING state)Loaded at:
Player.java:58Played at: Player.java:228 (via player.activate())Volume: 100% (1.0f)Description: Ambient tension/drone sound that plays once when gameplay begins, simulating a spaceship engine or background tension.This is played as a one-shot sound, not looped. For continuous engine sound, consider using Music with looping enabled instead.
Asset Loading
Loading Strategy
All assets are loaded synchronously in thecreate() method before the game starts:
Asset Paths
Assets are accessed using internal file paths relative to theassets/ directory:
assets/ root directory.
Asset Disposal
All assets must be disposed to prevent memory leaks:Asset Generation
The build system automatically generates anassets.txt manifest file listing all assets:
assets/assets.txt with contents like:
Asset Optimization
Texture Optimization
Texture Optimization
Current format: PNG for sprites, JPEG for backgroundsRecommendations:
- Use PNG for sprites with transparency
- Use JPEG for backgrounds (smaller size)
- Keep power-of-two dimensions when possible (32, 64, 128, 256, etc.)
- Use texture atlases for multiple small sprites
- Enable mipmapping for scaled textures
- Player: 64x64 (optimal)
- Obstacle: 62x48 (slightly odd, consider 64x48)
- Bullet: 10x20 (very small, efficient)
Audio Optimization
Audio Optimization
Current format: MP3Recommendations:
- Use OGG Vorbis for music (better compression, royalty-free)
- Use WAV for short sound effects (no decoding overhead)
- Reduce music bitrate (96-128 kbps is sufficient for games)
- Use mono audio for sound effects (stereo not needed)
- Keep sound effects under 1 second when possible
- Normalize audio files to consistent levels
- Avoid setting volume > 1.0 in code (causes clipping)
Loading Performance
Loading Performance
For larger games:
Adding New Assets
Add file to assets directory
Place your file in the appropriate subdirectory:
assets/images/for texturesassets/music/for background musicassets/sounds/for sound effects
Common Asset Issues
Asset not found error
Asset not found error
Error:
GdxRuntimeException: Couldn't load file: images/sprite.pngCauses:- File doesn’t exist in
assets/directory - Incorrect path (don’t include
assets/prefix) - Case-sensitive file system (Linux/Android)
- File not included in JAR/APK build
Music won't play
Music won't play
Common issues:
- Music file too large (>10MB may cause issues)
- Unsupported format (use OGG or MP3)
- Forgot to call
music.play() - Volume set to 0
- Music disposed too early
Memory leaks
Memory leaks
Symptom: Game crashes after playing for a while, especially on AndroidCause: Assets not disposed properlySolution:
- Always dispose textures, sounds, and music in
dispose() - Don’t create new textures every frame
- Remove bullets/obstacles from arrays when destroyed
- Use object pooling for frequently created/destroyed objects