本文整理汇总了Java中org.newdawn.slick.Animation.addFrame方法的典型用法代码示例。如果您正苦于以下问题:Java Animation.addFrame方法的具体用法?Java Animation.addFrame怎么用?Java Animation.addFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.newdawn.slick.Animation
的用法示例。
在下文中一共展示了Animation.addFrame方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
sheet = new PackedSpriteSheet("testdata/testpack.def", Image.FILTER_NEAREST);
rocket = sheet.getSprite("rocket");
SpriteSheet anim = sheet.getSpriteSheet("runner");
runner = new Animation();
for (int y=0;y<2;y++) {
for (int x=0;x<6;x++) {
runner.addFrame(anim.getSprite(x,y), 50);
}
}
}
示例2: init
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
this.container = container;
SpriteSheet sheet = new SpriteSheet("testdata/homeranim.png", 36, 65);
animation = new Animation();
for (int i=0;i<8;i++) {
animation.addFrame(sheet.getSprite(i,0), 150);
}
limited = new Animation();
for (int i=0;i<8;i++) {
limited.addFrame(sheet.getSprite(i,0), 150);
}
limited.stopAt(7);
manual = new Animation(false);
for (int i=0;i<8;i++) {
manual.addFrame(sheet.getSprite(i,0), 150);
}
pingPong = new Animation(sheet, 0,0,7,0,true,150,true);
pingPong.setPingPong(true);
container.getGraphics().setBackground(new Color(0.4f,0.6f,0.6f));
}
示例3: init
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
public void init(GameContainer container) throws SlickException //fait par VS, JD et FS
{
//Initialisation of animation when BOOOOM !
explosionAnimation = new Animation();
explosionImage1 = new Image ("boom1.png");
explosionImage2 = new Image ("boom2.png");
explosionImage3 = new Image ("boom3.png");
explosionImage4 = new Image ("boom4.png");
explosionAnimation.addFrame(explosionImage1, 25);
explosionAnimation.addFrame(explosionImage2, 35);
explosionAnimation.addFrame(explosionImage3, 35);
explosionAnimation.addFrame(explosionImage4, 150);
explosionAnimation.setLooping(false);
//Graphic aspect
ttf = new TrueTypeFont(font, true);
container.getGraphics().setBackground(new Color(193, 184, 176));
//Input management on TextArea
pseudoEntry = new TextArea(20,20,150,20);
container.getInput().addKeyListener(pseudoEntry);
container.getInput().addMouseListener(pseudoEntry);
pseudoEntry.setPosition(grid.getRightPosition(), getNextCommandPosition(0));
}
示例4: Nazi
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
public Nazi(float x, float y) throws SlickException {
super(x, y);
dos = null;
lifeAddTimeout = new Random().nextInt(30);
naziSheet = new SpriteSheet("org/dosimonline/res/sprites/nazi.png", 20,
55);
naziWalkLeft = new Animation();
naziWalkLeft.setAutoUpdate(true);
naziWalkLeft.addFrame(
naziSheet.getSprite(0, 0).getFlippedCopy(true, false), 150);
naziWalkLeft.addFrame(
naziSheet.getSprite(1, 0).getFlippedCopy(true, false), 150);
naziWalkRight = new Animation();
naziWalkRight.setAutoUpdate(true);
naziWalkRight.addFrame(naziSheet.getSprite(0, 0), 150);
naziWalkRight.addFrame(naziSheet.getSprite(1, 0), 150);
addType("Anti Semitic"); // Gilnaa: lol wut
setHitBox(0, 20, 20, 35);
}
示例5: spriteToAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
public static @Nonnull Animation spriteToAnimation(@Nonnull Image img, int horizontalTiles, int verticalTiles, int frameDuration)
{
SpriteSheet sheet = new SpriteSheet(img, img.getWidth() / horizontalTiles, img.getHeight() / verticalTiles);
Animation anim = new Animation();
anim.setAutoUpdate(true);
for (int y = 0; y < sheet.getVerticalCount(); y++)
{
for (int x = 0; x < sheet.getHorizontalCount(); x++)
{
anim.addFrame(sheet.getSprite(x, y), frameDuration);
}
}
return anim;
}
示例6: loadAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
private Animation loadAnimation(SpriteSheet spriteSheet, int startX, int endX, int y) {
Animation animation = new Animation();
for (int x = startX; x < endX; x++) {
animation.addFrame(spriteSheet.getSprite(x, y), 100);
}
return animation;
}
示例7: getAnimationFromFolder
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
/**
* Get Animation by load all PNG file in specific folder by name order
* @param directory Images folder
* @param duration Duration of each frame
* @return Animation
*/
public static Animation getAnimationFromFolder(String directory, int duration) {
Animation temp = new Animation();
String[] imgs = getFiles(directory, "png");
for (int i=0; i<imgs.length; i++) {
try {
temp.addFrame(new Image(directory+"/"+imgs[i]), duration);
} catch (SlickException e) {
e.printStackTrace();
}
}
return temp;
}
示例8: setMovingAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
protected HashMap<Facing, Animation> setMovingAnimation(Image[] images, int frameDuration,
HashMap<Facing, Animation> movingAnim) {
movingAnim = new HashMap<Facing, Animation>();
movingAnim.put(Facing.RIGHT, new Animation(images, frameDuration));
Animation facingLeftAnimation = new Animation();
for (Image i : images) {
facingLeftAnimation.addFrame(i.getFlippedCopy(true, false), frameDuration);
}
movingAnim.put(Facing.LEFT, facingLeftAnimation);
return movingAnim;
}
示例9: loadAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
protected Animation loadAnimation(SpriteSheet spriteSheet, int startX, int endX, int startY, int endY, boolean looped, int speed) {
Animation animation = new Animation();
for (int y = startY; y < endY; y++) {
for (int x = startX; x < endX; x++) {
animation.addFrame(spriteSheet.getSprite(x, y), speed);
}
}
animation.setLooping(looped);
return animation;
}
示例10: loadAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
protected Animation loadAnimation(SpriteSheet spriteSheet, int x, int y, int maxX) {
Animation ret = new Animation();
for (;x < maxX; ++x) {
ret.addFrame(spriteSheet.getSprite(x, y), 100);
}
return ret;
}
示例11: Dos
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
public Dos(float x, float y) throws SlickException {
super(x, y);
SpriteSheet dosSheet = new SpriteSheet(
"org/dosimonline/res/sprites/dos.png", 20, 36);
dosWalkLeft = new Animation();
dosWalkLeft.setAutoUpdate(true);
dosWalkLeft.addFrame(
dosSheet.getSprite(0, 0).getFlippedCopy(true, false), 150);
dosWalkLeft.addFrame(
dosSheet.getSprite(1, 0).getFlippedCopy(true, false), 150);
dosWalkRight = new Animation();
dosWalkRight.setAutoUpdate(true);
dosWalkRight.addFrame(dosSheet.getSprite(0, 0), 150);
dosWalkRight.addFrame(dosSheet.getSprite(1, 0), 150);
dosStanding = dosSheet.getSprite(0, 0);
dosJumping = dosSheet.getSprite(2, 0);
define("right", Input.KEY_D);
define("left", Input.KEY_A);
define("up", Input.KEY_W);
define("q", Input.KEY_Q);
setHitBox(0, 0, dosStanding.getWidth(), dosStanding.getHeight());
addType("Dos");
score = 0;
life = 5;
velocityY = 0;
jumpAllowed = false;
}
示例12: newAnimation
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
public Animation newAnimation()
{
SpriteSheetCounted sprite = getSpriteSheet();
if (sprite == null)
{
return null;
}
Animation anim = new Animation();
anim.setAutoUpdate(true);
for (int tile = 0; tile < sprite.getTilesCount(); tile++)
{
int duration;
if (tile < this.frameDuration.length)
{
duration = this.frameDuration[tile];
}
else
{
duration = this.frameDuration[this.frameDuration.length-1];
}
anim.addFrame(sprite.getSubImage(tile), duration);
}
return anim;
}
示例13: init
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
@Override
public void init(GameContainer arg0, StateBasedGame arg1) throws SlickException {
player = new Player();
buildings = new ArrayList<>();
goons = new ArrayList<>();
bullets = new ArrayList<>();
playerImage = new Image("res/player.png");
playerImage.setFilter(Image.FILTER_NEAREST);
playerJump = new Image("res/playerjump.png");
playerJump.setFilter(Image.FILTER_NEAREST);
cannonImage = new Image("res/cannon.png");
cannonImage.setFilter(Image.FILTER_LINEAR);
cannonImage.setCenterOfRotation(Player.CANNON_CENTER_X, Player.CANNON_CENTER_Y);
SpriteSheet playerSS = new SpriteSheet("res/player_run.png", 60, 75);
playerRunRight = new Animation(playerSS, RUN_ANIMATION_SPEED);
playerRunLeft = new Animation();
int ssw = playerSS.getHorizontalCount(), ssh = playerSS.getVerticalCount();
for (int y = 0; y < ssh; y++) {
for (int x = 0; x < ssw; x++) {
playerRunLeft.addFrame(playerSS.getSprite(x, y).getFlippedCopy(true, false), RUN_ANIMATION_SPEED);
}
}
bulletAnim = new Animation(new SpriteSheet("res/bullet.png", 30, 30), BULLET_ANIMATION_SPEED);
buildingTexture = new Image("res/building.png");
buildingLastRow = buildingTexture.getSubImage(0, buildingTexture.getHeight() - 1, buildingTexture.getWidth(), 1);
buildingTexture.setFilter(Image.FILTER_NEAREST);
buildingLastRow.setFilter(Image.FILTER_NEAREST);
graffitiImages = new Image[NUM_GRAFFITI * 2];
for (int i = 0; i < NUM_GRAFFITI; i++) {
graffitiImages[i] = new Image("res/graffiti" + i + ".png");
graffitiImages[i + NUM_GRAFFITI] = graffitiImages[i].getFlippedCopy(true, false);
}
graffiti = new ArrayList<>();
mainTheme = new Music("res/main.ogg");
try {
partsys = ParticleIO.loadConfiguredSystem("res/particle.xml");
} catch (IOException e) {
e.printStackTrace();
}
fireExplosion = (ConfigurableEmitter)partsys.getEmitter(0);
blueExplosion = (ConfigurableEmitter)partsys.getEmitter(1);
fireExplosion.setEnabled(false);
blueExplosion.setEnabled(false);
fireCannon = new Sound("res/firecannon.ogg");
highExplosion = new Sound("res/highexplosion.ogg");
softExplosion = new Sound("res/softexplosion.ogg");
hurtSound = new Sound("res/hurt.ogg");
basicGoon = new Image("res/plasticbag.png");
strongGoon = new Image("res/trashbag.png");
flyingGoon = new Animation(new SpriteSheet("res/tshirt.png", 50, 50), 200);
background = new Image("res/sunset.png");
background.setFilter(Image.FILTER_NEAREST);
camx = 0;
camy = 0;
camvx = 0;
}
示例14: init
import org.newdawn.slick.Animation; //导入方法依赖的package包/类
/**
* @see org.newdawn.slick.BasicGame#init(org.newdawn.slick.GameContainer)
*/
public void init(GameContainer container) throws SlickException {
// load the sprites and tiles, note that underneath the texture
// will be shared between the sprite sheet and tilemap
SpriteSheet sheet = new SpriteSheet("testdata/scroller/sprites.png",32,32);
// load the tilemap created the TileD tool
map = new TiledMap("testdata/scroller/map.tmx");
// build a collision map based on tile properties in the TileD map
blocked = new boolean[map.getWidth()][map.getHeight()];
for (int x=0;x<map.getWidth();x++) {
for (int y=0;y<map.getHeight();y++) {
int tileID = map.getTileId(x, y, 0);
String value = map.getTileProperty(tileID, "blocked", "false");
if ("true".equals(value)) {
blocked[x][y] = true;
}
}
}
// caculate some layout values for rendering the tilemap. How many tiles
// do we need to render to fill the screen in each dimension and how far is
// it from the centre of the screen
widthInTiles = container.getWidth() / TILE_SIZE;
heightInTiles = container.getHeight() / TILE_SIZE;
topOffsetInTiles = heightInTiles / 2;
leftOffsetInTiles = widthInTiles / 2;
// create the player sprite based on a set of sprites from the sheet loaded
// above (tank tracks moving)
player = new Animation();
for (int frame=0;frame<7;frame++) {
player.addFrame(sheet.getSprite(frame,1), 150);
}
player.setAutoUpdate(false);
// update the vector of movement based on the initial angle
updateMovementVector();
Log.info("Window Dimensions in Tiles: "+widthInTiles+"x"+heightInTiles);
}