当前位置: 首页>>代码示例>>Java>>正文


Java Animation类代码示例

本文整理汇总了Java中org.newdawn.slick.Animation的典型用法代码示例。如果您正苦于以下问题:Java Animation类的具体用法?Java Animation怎么用?Java Animation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Animation类属于org.newdawn.slick包,在下文中一共展示了Animation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
		}
	}
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:19,代码来源:PackedSheetTest.java

示例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));
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:25,代码来源:AnimationTest.java

示例3: Monster4

import org.newdawn.slick.Animation; //导入依赖的package包/类
public Monster4(int playerNumber) throws SlickException {
        super();
        skillIcons = new Image[]{
                new Image("Assets/Graphics/Monster and Human Sprites/Root/Root - 1 Leaf Icon.png"),
                new Image("Assets/Graphics/Monster and Human Sprites/Flame/Firefly.png"),
                new Image("Assets/Graphics/Monster and Human Sprites/Flame/X-Burner.png")
        };
        if (playerNumber == 1) {
            animationIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Root/Root - Idle P1.png", 600, 300, 1), frameDurationMonsterIdle);
            animationHumanIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Root/Root - Human P1.jpg", 150, 150, 1), frameDurationHumanIdle);

            animationSkill1 = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Root/Root - 1 Leaf Icon P1.png", 600, 300, 1), frameDurationSkill1);
            animationSkill2 = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Root/Root - 1 Leaf Icon P1.png", 600, 300, 1), frameDurationSkill2);
            animationSkillUlt = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Root/Root - 1 Leaf Icon P1.png", 600, 300, 1), frameDurationSkillUlt);

            // TODO uncomment when sprites for player2 (flipper player1 sprites) are done
//        } else if (playerNumber == 2) {
//            animationIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Idle P2.png", 600, 300, 1), 250);
//            animationHumanIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Human P2.png", 600, 300, 1), 250);

//            animationSkill1 = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 1 Blistol P2.png", 600, 300, 1), 250);
//            animationSkill2 = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 2 Gatling P2.png", 600, 300, 1), 250);
//            animationSkillUlt = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 3 Bluezooka P2.png", 600, 300, 1), 250);
        }

    }
 
开发者ID:earlmalaki,项目名称:BeatBitBeat,代码行数:27,代码来源:Monster4.java

示例4: Monster6

import org.newdawn.slick.Animation; //导入依赖的package包/类
public Monster6(int playerNumber) throws SlickException {
        super();

        if (playerNumber == 1) {
            animationIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Idle P1.png", 600, 300, 1), 250);
            animationHumanIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Human P1.jpg", 600, 300, 1), 250);

            animationSkill1 = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - 1 Blistol P1.png", 600, 300, 1), 250);
            animationSkill2 = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - 2 Gatling P1.png", 600, 300, 1), 250);
            animationSkillUlt = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - 3 Bluezooka P1.png", 600, 300, 1), 250);

            // TODO uncomment when sprites for player2 (flipper player1 sprites) are done
//        } else if (playerNumber == 2) {
//            animationIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Idle P2.png", 600, 300, 1), 250);
//            animationHumanIdle = new Animation(new SpriteSheet("Assets/Graphics/Monster and Human Sprites/Blueffy/Blueffy - Human P2.png", 600, 300, 1), 250);

//            animationSkill1 = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 1 Blistol P2.png", 600, 300, 1), 250);
//            animationSkill2 = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 2 Gatling P2.png", 600, 300, 1), 250);
//            animationSkillUlt = new Animation(new SpriteSheet("Assets/Graphics/Monster Skills Sprites/Blueffy/Blueffy - 3 Bluezooka P2.png", 600, 300, 1), 250);
        }

    }
 
开发者ID:earlmalaki,项目名称:BeatBitBeat,代码行数:23,代码来源:Monster6.java

示例5: init

import org.newdawn.slick.Animation; //导入依赖的package包/类
@Override
public void init(GameContainer container, StateBasedGame game) throws SlickException {
	this.anim = new Animation(this.sprite, 75);
	this.anim.setCurrentFrame(Utils.getRandomNumber(13));
	this.anim.start();
	
	BodyDef def = new BodyDef();
	def.position.set(this.position);
	this.objBody = this.world.createBody(def);

	PolygonDef sd = new PolygonDef();
	sd.setAsBox(0.3f, 0.3f);
	sd.userData = "orb"; //Indica que o objeto � uma orb.
	this.objBody.createShape(sd);
	this.objBody.setMassFromShapes();
	this.objBody.setUserData(this);
}
 
开发者ID:intentor,项目名称:telyn,代码行数:18,代码来源:OrbObject.java

示例6: 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));
}
 
开发者ID:UTBroM,项目名称:2COA,代码行数:26,代码来源:WindowGame.java

示例7: Animator

import org.newdawn.slick.Animation; //导入依赖的package包/类
public Animator(Animator animator) {
    this.animations = new HashMap<>();
    for (Map.Entry entry : animator.animations.entrySet()) {
        EnumAnimation type = (EnumAnimation) entry.getKey();
        List<Animation> values = (ArrayList<Animation>) entry.getValue();
        List<Animation> newValues = new ArrayList<>();
        for (Animation value : values) {
            newValues.add(value.copy());
        }
        this.addElement(type, newValues);
    }
    this.current = animator.current;
    this.index = animator.index;
    this.printable = animator.printable;
    this.deleted = animator.deleted;
    this.needUpdate = animator.needUpdate;
    this.filter = animator.filter;
    this.activatedTimer = new ActivatedTimer(animator.activatedTimer);
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:20,代码来源:Animator.java

示例8: loadPlayerFeet

import org.newdawn.slick.Animation; //导入依赖的package包/类
public static Animation[] loadPlayerFeet() {
	SpriteSheet sprites = new SpriteSheet(loadImage("feet.png"), 64, 64);

	Animation[] model = new Animation[8];

	Image[] frames = new Image[8];
	for (int angle = 0, j = 0; angle < 360; angle += 45, j++) {
		for (int i = 0; i < 8; i++) {
			Image temp = sprites.getSprite(0, i);
			temp.rotate(angle);
			frames[i] = temp;
		}
		model[j] = new Animation(frames, 100);
	}

	return model;
}
 
开发者ID:JavaJumperStudios,项目名称:Saboteur,代码行数:18,代码来源:RessourceManager.java

示例9: TimeMeter

import org.newdawn.slick.Animation; //导入依赖的package包/类
public TimeMeter(float xPos, float yPos, float xOffset, float yOffset, float entityWidth, float entityHeight, int timeLimit) throws SlickException {
	
	// Basic attributes
	this.xPos = xPos;
	this.yPos = yPos;
	originalXPos = xPos;
	originalYPos = yPos;
	this.xOffset = xOffset;
	this.yOffset = yOffset;
	width = height = 30;
	
	// Visibility
	visible = false;
	
	// Create the Circle SpriteSheet
	circle = ResourceLoader.getInstance().timeSpriteSheet;
	circle.setFilter(Image.FILTER_NEAREST);
	timeAnimation = new Animation(circle, 0, 0, 26, 0, true, 1, true);
	timeAnimation.setLooping(false);
	
	// Calculate the animation speed based on the Time Limit
	this.timeLimit = timeLimit;
	animationSpeed = 1000f / timeLimit / ((float)timeAnimation.getFrameCount() - 1f);
	timeAnimation.setSpeed(animationSpeed);
}
 
开发者ID:lucas-tulio,项目名称:awesome-game-store,代码行数:26,代码来源:TimeMeter.java

示例10: render

import org.newdawn.slick.Animation; //导入依赖的package包/类
public void render(Graphics g)
{
    for (Animation[] animations : mAnimations) {
   	    if (animations[mDirection] != null) {
   //	        g.drawAnimation(mAnimations[mDirection], mPosition.x - mSize.x / 2, mPosition.y - mSize.y / 2);
   	        animations[mDirection].draw(mPosition.x - mSize.x / 2, mPosition.y - mSize.y / 2, mSize.x, mSize.y);
   	    } else if (animations[0] != null) {
   	        animations[0].draw(mPosition.x - mSize.x / 2, mPosition.y - mSize.y / 2, mSize.x, mSize.y);
   	    }
    }
    
    if (mGameMode.isDebug()) {
	    g.draw(mBounds);
	    if (mVision != null) {
	        g.draw(mVision);
	    }
	}
}
 
开发者ID:AlexMog,项目名称:MMO-Rulemasters-World,代码行数:19,代码来源:Entity.java

示例11: setSkin

import org.newdawn.slick.Animation; //导入依赖的package包/类
public void setSkin() {
    for (String skin : mSkinParts) {
        Image img = (Image) DatasManager.getInstance().getFile(skin);
        SpriteSheet s = new SpriteSheet(img, img.getWidth() / 3, img.getHeight() / 4);
        Animation[] anim = new Animation[8];
        anim[0] = loadAnimation(s, 0, 0, 3); // Haut
        anim[1] = loadAnimation(s, 0, 1, 3); // Gauche
        anim[2] = loadAnimation(s, 0, 2, 3); // Droite
        anim[3] = loadAnimation(s, 0, 3, 3); // Bas
        anim[4] = loadAnimation(s, 1, 0, 2); // Haut qui bouge pas
        anim[5] = loadAnimation(s, 1, 1, 2); // Gauche qui bouge pas
        anim[6] = loadAnimation(s, 1, 2, 2); // Droite qui bouge pas
        anim[7] = loadAnimation(s, 1, 3, 2); // Bas qui bouge pas
        mAnimations.add(anim);
    }
}
 
开发者ID:AlexMog,项目名称:MMO-Rulemasters-World,代码行数:17,代码来源:OnlineEntity.java

示例12: AnimationRenderComponent

import org.newdawn.slick.Animation; //导入依赖的package包/类
/**
 * Create a new AnimationRenderComponent based on the information provided
 *
 * @param frames
 *          the individual animation frames to be displayed in order
 * @param speed
 *          the speed at which the images change
 * @param width
 *          the width of the images
 * @param height
 *          the height of the images
 * @param looping
 *          whether the first frame shall be displayed when the animation is
 *          over or not.
 */
public AnimationRenderComponent(Image[] frames, float speed, float width, float height, boolean looping) {
    super("AnimationRenderComponent");

    // set the size for this component
    size = new Vector2f(width, height);

    // create a new Animation object based on the frames with a duration of 1
    animation = new Animation(frames, 1);

    // assign the other parameters (speed, looping mode)
    animation.setSpeed(speed);
    animation.setLooping(looping);

    // start the animation
    animation.start();
}
 
开发者ID:joshimoo,项目名称:Gorillaz,代码行数:32,代码来源:AnimationRenderComponent.java

示例13: 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);
}
 
开发者ID:Dosim-Online,项目名称:DosimOnline.Models,代码行数:24,代码来源:Nazi.java

示例14: 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;
}
 
开发者ID:Periapsis,项目名称:aphelion,代码行数:17,代码来源:SwissArmyKnife.java

示例15: Player

import org.newdawn.slick.Animation; //导入依赖的package包/类
public Player(Vector2f pos) {
	super(pos);
	oxygenConsumptionPerSecond = (int) ConfigManager.playerOxygenConsumption;
	this.gbtype = GameBodyType.PLAYER;
	this.setMaxHealth(20);
	this.setHealth(20);
	this.accFactor = ConfigManager.playerAcc;
	halfSize.set(0.4f, 0.4f);
	try {
		headSprites = new SpriteSheet("assets/textures/animperso.png",256,256);
		headAnimation = new Animation(headSprites, 600);
		headAnimation.setPingPong(true);
		bodySprites = new SpriteSheet("assets/textures/playerBody.png",256,256);
		featherSprites = new SpriteSheet("assets/textures/feather.png",256,256);
		featherAnimation = new Animation(featherSprites, 50);
		featherAnimation.setPingPong(true);
	} catch (SlickException e) {
		e.printStackTrace();
	}
			
	inventory = new Inventory(5,this);
	actionZone = new ActionZone(actionRange, position.x, position.y);
	actionZone.init();
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:25,代码来源:Player.java


注:本文中的org.newdawn.slick.Animation类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。