Android Open Source - lamp-game Level Complete Window






From Project

Back to project page lamp-game.

License

The source code is released under:

GNU General Public License

If you think the Android project lamp-game listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lifestudio.extras;
/* www  .  j a va  2  s  .com*/
import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.sprite.TiledSprite;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.opengl.texture.region.*;

import com.lifestudio.manager.ResourcesManager;

public class LevelCompleteWindow extends Sprite
{
    private TiledSprite star1;
    private TiledSprite star2;
    private TiledSprite star3;
    
    public enum StarsCount
    {
        ONE,
        TWO,
        THREE
    }
    
    public LevelCompleteWindow(VertexBufferObjectManager pSpriteVertexBufferObject)
    {
        super(0, 0, 650, 400, ResourcesManager.getInstance().complete_window_region, pSpriteVertexBufferObject);
        attachStars(pSpriteVertexBufferObject);
    }
    
    private void attachStars(VertexBufferObjectManager pSpriteVertexBufferObject)
    {
        star1 = new TiledSprite(150, 150, ResourcesManager.getInstance().complete_stars_region, pSpriteVertexBufferObject);
        star2 = new TiledSprite(325, 150, ResourcesManager.getInstance().complete_stars_region, pSpriteVertexBufferObject);
        star3 = new TiledSprite(500, 150, ResourcesManager.getInstance().complete_stars_region, pSpriteVertexBufferObject);
        
        attachChild(star1);
        attachChild(star2);
        attachChild(star3);
    }
    
    /**
     * Change star`s tile index, depends on stars count.
     * @param starsCount
     */
    public void display(StarsCount starsCount, Scene scene, Camera camera)
    {
        // Change stars tile index, based on stars count (1-3)
        switch (starsCount)
        {
            case ONE:
                star1.setCurrentTileIndex(0);
                star2.setCurrentTileIndex(1);
                star3.setCurrentTileIndex(1);
                break;
            case TWO:
                star1.setCurrentTileIndex(0);
                star2.setCurrentTileIndex(0);
                star3.setCurrentTileIndex(1);
                break;
            case THREE:
                star1.setCurrentTileIndex(0);
                star2.setCurrentTileIndex(0);
                star3.setCurrentTileIndex(0);
                break;
        }
        
        
        // Hide HUD
        camera.getHUD().setVisible(false);
        
        // Disable camera chase entity
        camera.setChaseEntity(null);
        
        // Attach our level complete panel in the middle of camera
        setPosition(camera.getCenterX(), camera.getCenterY());
        scene.attachChild(this);
    }
}




Java Source Code List

com.lifestudio.GameActivity.java
com.lifestudio.base.BaseScene.java
com.lifestudio.extras.LevelCompleteWindow.java
com.lifestudio.manager.ResourcesManager.java
com.lifestudio.manager.SceneManager.java
com.lifestudio.object.Player.java
com.lifestudio.scene.GameScene.java
com.lifestudio.scene.LoadingScene.java
com.lifestudio.scene.MainMenuScene.java
com.lifestudio.scene.SplashScene.java