Android Open Source - GameWorker Sprite Manager






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;
//ww  w .  j a  va  2 s .  c o  m
import java.util.LinkedList;

import android.graphics.Canvas;

/**
 * This class manages a series of sprites that are added to it.
 * @author AL
 *
 */
public class SpriteManager
{
   /**
    * List of sprites added.
    */
    private static LinkedList<Sprite> spriteList;
    
    /**
     * Constructor
     */
    public SpriteManager()
    {
  spriteList = new LinkedList<Sprite>();
    }
    
    public void update()
    {
  for(Sprite spriteItem: spriteList)
  {
      spriteItem.update();
  }
    }
    
    /**
     * Draws the sprites that are in the list.
     * @param canvas
     */
    public void render(Canvas canvas)
    {
  for(Sprite spriteItem: spriteList)
  {
      spriteItem.draw(canvas);
  }
    }
    
    /**
     * Function used to add sprite to the manager.
     * @param sprite
     */
    public void addSprite(Sprite sprite)
    {
  spriteList.add(sprite);
    }
    
}




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