Android Open Source - GameWorker Sprite






From Project

Back to project page GameWorker.

License

The source code is released under:

Apache License

If you think the Android project GameWorker 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.al.gameengine.sprite;
/*from   ww  w. j  av a  2s.  co m*/
import android.graphics.Bitmap;
import android.graphics.Canvas;

import com.al.gameengine.Animation;
import com.al.gameengine.Direction;
import com.al.gameengine.Position;

public class Sprite
{
    Position pos;
    Bitmap mainImage;
    Direction moveDirection;
    Animation running;
    Animation action;
    Canvas canvas;
    
    public Sprite()
    {
  pos = new Position();
  running = new Animation();
  action = new Animation();
//  canvas = new Canvas();
    }
    
    public Sprite(int initialX, int initialY)
    {
  this();
  this.pos.setX(initialX);
  this.pos.setY(initialY);
  
    }
    
    public Sprite(int initialX, int initialY, Bitmap bitmap)
    {
  this(initialX, initialY);
  mainImage = bitmap;
    }
    
    public void update()
    {
  
    }
    
    public void draw(Canvas canvas)
    {
  setCanvas(canvas);
  render();
    }
    
    public void render()
    {
  if(canvas != null)
  {
      canvas.drawBitmap(mainImage, pos.getX(), pos.getY(), null);
  }
    }
    
    public void setImage(Bitmap image)
    {
  mainImage = image;
    }
    
    public Bitmap getImage()
    {
  return mainImage;
    }
    
    public Position getPosition()
    {
  return pos;
    }
    
    public void setPosition(Position pos)
    {
  this.pos = pos;
    }
    
    public void setCanvas(Canvas canvas)
    {
  this.canvas = canvas;
    }
   
}




Java Source Code List

com.al.gameengine.Animation.java
com.al.gameengine.Background.java
com.al.gameengine.Direction.java
com.al.gameengine.GameEngine.java
com.al.gameengine.Position.java
com.al.gameengine.Scene.java
com.al.gameengine.sprite.GameView.java
com.al.gameengine.sprite.SpriteManager.java
com.al.gameengine.sprite.Sprite.java
com.al.gameworker.MainActivity.java