Android Open Source - RockFall-Android Sprite Sheet






From Project

Back to project page RockFall-Android.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project RockFall-Android 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 eu.raffprta.rockfall.core.sprite;
//w w w .j a  va2s  .c om
import android.util.Log;
import android.content.res.*;
import android.graphics.*;

/**
 * This class resembles a SpriteSheet object -
 * though, a small misnomer as we also have methods
 * that concern itself with loading the full image
 * where it's more plausible to do so!
 * @author Raffaello Perrotta
 *
 */

public class SpriteSheet{

    private Resources res;
    private int id;


    public SpriteSheet(Resources res, int id){
        this.res = res;
        this.id = id;
    }

    /**
     *
     * @return the whole image, relating to an image file
     */

    protected Bitmap getWhole(){
        Bitmap img = BitmapFactory.decodeResource(this.res, this.id);
        return img;
    }


    /**
     * Gets a tranche of the SpriteSheet based on the parameters.
     */

    protected Bitmap getCell(int col, int row, int cellWidth, int cellHeight){
        Bitmap img = BitmapFactory.decodeResource(this.res, this.id);
        Bitmap subImg = img.createBitmap(img, col*cellWidth, row*cellHeight, cellWidth, cellHeight);
        return subImg;

    }



}




Java Source Code List

eu.raffprta.rockfall.app.GameCanvas.java
eu.raffprta.rockfall.app.GameIntent.java
eu.raffprta.rockfall.app.GameScreen.java
eu.raffprta.rockfall.app.MainGame.java
eu.raffprta.rockfall.app.MenuCanvas.java
eu.raffprta.rockfall.app.SpriteContainer.java
eu.raffprta.rockfall.app.StopWatch.java
eu.raffprta.rockfall.app.TouchHandler.java
eu.raffprta.rockfall.core.entity.AbstractEntity.java
eu.raffprta.rockfall.core.entity.EntityFactory.java
eu.raffprta.rockfall.core.entity.Entity.java
eu.raffprta.rockfall.core.entity.FallableType.java
eu.raffprta.rockfall.core.entity.Fallable.java
eu.raffprta.rockfall.core.entity.Powerup.java
eu.raffprta.rockfall.core.entity.Protagonist.java
eu.raffprta.rockfall.core.entity.Rock.java
eu.raffprta.rockfall.core.sprite.SpriteFactory.java
eu.raffprta.rockfall.core.sprite.SpriteSheet.java
eu.raffprta.rockfall.core.sprite.Sprite.java