Android Open Source - hiddenmarble Sprite Helper






From Project

Back to project page hiddenmarble.

License

The source code is released under:

Apache License

If you think the Android project hiddenmarble 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.mygdx.hiddenmarble.utils;
/*  w  w w .  ja v a  2s . co  m*/
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;

/** Creates and initialize sprites. */
public final class SpriteHelper {
    private SpriteHelper() {
    }
    
    /**
     * Creates a sprite and centers it at (0, 0).
     * 
     * @param  texture the texture for the sprite
     * @param  width the width of the sprite
     * @param  height the height of the sprite
     * @return a new sprite
     */
    public static Sprite getSprite(Texture texture, float width, float height) {
        return getSprite(texture, width, height, 0.0f, 0.0f);
    }
    
    /**
     * Creates a sprite and centers it at the specified location.
     * 
     * @param  texture the texture for the sprite
     * @param  width the width of the sprite
     * @param  height the height of the sprite
     * @param  x x-coordinate of the sprite's position
     * @param  y y-coordinate of the sprite's position
     * @return a new sprite
     */
    public static Sprite getSprite(Texture texture, float width, float height,
            float x, float y) {
        
        Sprite sprite = new Sprite(texture);
        sprite.setSize(width, height);
        sprite.setOriginCenter();
        sprite.setCenter(x, y);
        return sprite;
    }    
}




Java Source Code List

com.mygdx.hiddenmarble.android.AndroidLauncher.java
com.mygdx.hiddenmarble.desktop.DesktopLauncher.java
com.mygdx.hiddenmarble.entities.AbstractDynamicEntity.java
com.mygdx.hiddenmarble.entities.AbstractEntity.java
com.mygdx.hiddenmarble.entities.Borders.java
com.mygdx.hiddenmarble.entities.DefaultBorders.java
com.mygdx.hiddenmarble.entities.DefaultMarble.java
com.mygdx.hiddenmarble.entities.DefaultMazeBox.java
com.mygdx.hiddenmarble.entities.DynamicEntity.java
com.mygdx.hiddenmarble.entities.Entity.java
com.mygdx.hiddenmarble.entities.Marble.java
com.mygdx.hiddenmarble.entities.Material.java
com.mygdx.hiddenmarble.entities.MazeBox.java
com.mygdx.hiddenmarble.entities.MazeFixtureDef.java
com.mygdx.hiddenmarble.ui.GameScreen.java
com.mygdx.hiddenmarble.ui.HiddenMarble.java
com.mygdx.hiddenmarble.ui.WorldRenderer.java
com.mygdx.hiddenmarble.utils.Assets.java
com.mygdx.hiddenmarble.utils.BodyHelper.java
com.mygdx.hiddenmarble.utils.MazeHelper.java
com.mygdx.hiddenmarble.utils.SaveState.java
com.mygdx.hiddenmarble.utils.Serialization.java
com.mygdx.hiddenmarble.utils.SpriteHelper.java
com.mygdx.hiddenmarble.world.GameWorldAdapter.java
com.mygdx.hiddenmarble.world.GameWorldListener.java
com.mygdx.hiddenmarble.world.GameWorld.java