00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 package org.classroomgaming.cgp;
00022
00023 import org.classroomgaming.cgp.*;
00024
00030 public class SamplePlayerCharacterSpawner implements Spawner {
00031
00032 AnimatedSprite anim;
00033 PlayerMover pm;
00042 public SamplePlayerCharacterSpawner(String down, String up, String left, String right) {
00043 SpriteAnimationFrame downFrames[] = {new SpriteAnimationFrame(down, ImageManager.getInstance().load(down), 1)};
00044 SpriteAnimationFrame upFrames[] = {new SpriteAnimationFrame(up, ImageManager.getInstance().load(up), 1)};
00045 SpriteAnimationFrame leftFrames[] = {new SpriteAnimationFrame(left, ImageManager.getInstance().load(left), 1)};
00046 SpriteAnimationFrame rightFrames[] = {new SpriteAnimationFrame(right, ImageManager.getInstance().load(right), 1)};
00047 SpriteAnimation animList[] = {new SpriteAnimation("down", downFrames),
00048 new SpriteAnimation("up", upFrames),
00049 new SpriteAnimation("left", leftFrames),
00050 new SpriteAnimation("right", rightFrames)};
00051
00052 anim = new AnimatedSprite(animList);
00053 pm = new PlayerMover();
00054
00055 }
00056
00057
00063 public Entity create(String name) {
00064 Entity obj = new Entity(name);
00065 obj.addModule("AnimatedSprite", anim);
00066 obj.addModule("PlayerMover", pm);
00067 return obj;
00068 }
00069 }