當前位置: 首頁>>代碼示例>>Java>>正文


Java Animation.setPlayMode方法代碼示例

本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Animation.setPlayMode方法的典型用法代碼示例。如果您正苦於以下問題:Java Animation.setPlayMode方法的具體用法?Java Animation.setPlayMode怎麽用?Java Animation.setPlayMode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.badlogic.gdx.graphics.g2d.Animation的用法示例。


在下文中一共展示了Animation.setPlayMode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: init

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public void init() {

        CURRENT_STATE = PONY_STATE.STANDING;
        isFacingRight = false;

        runAnimation = new Animation(FRAME_DURATION, AssetDoctor.getTextureRegion_ATLAS("pony_01"), AssetDoctor.getTextureRegion_ATLAS("pony_02"));
        runAnimation.setPlayMode(Animation.PlayMode.LOOP);

        cheerAnimation = new Animation(FRAME_DURATION, AssetDoctor.getTextureRegion_ATLAS("pony_cheer_00"), AssetDoctor.getTextureRegion_ATLAS("pony_cheer_01"), AssetDoctor.getTextureRegion_ATLAS("pony_cheer_02"));
        cheerAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

        currentSprite = new Sprite(AssetDoctor.getSprite("pony"));
        resizeSprite(currentSprite);
        moveToX = x;
        moveToY = y;
    }
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:17,代碼來源:Pony.java

示例2: AnimatedSprite

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public AnimatedSprite(String key, float totalDuration, Integer numLoops, State state) {
    super();

    Array<AtlasRegion> frames = AssetManager.getInstance().getTextureRegions(key);
    float frameDuration = ConversionUtils.ms2s(totalDuration / frames.size);
    rawAnimation = new Animation(frameDuration, frames);

    this.numLoops = numLoops;
    if (numLoops == null || numLoops > 1) {
        rawAnimation.setPlayMode(PlayMode.LOOP);
    }

    this.state = state;

    setRegion(getCurrentFrame());
}
 
開發者ID:alexschimpf,項目名稱:joe,代碼行數:17,代碼來源:AnimatedSprite.java

示例3: createAnimation

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public static Animation createAnimation(TextureAtlas atlas,
        String regionName, float frameDuration, Animation.PlayMode mode) {
    ArrayList<TextureRegion> frames = new ArrayList<>();

    int idx = 0;
    TextureAtlas.AtlasRegion region;

    while ((region = atlas.findRegion(regionName, idx)) != null) {
        frames.add(region);
        idx++;
    }

    TextureRegion[] regions = new TextureRegion[idx];
    Animation anim = new Animation(frameDuration, frames.toArray(regions));
    anim.setPlayMode(mode);        
    return anim;
}
 
開發者ID:jh62,項目名稱:Battle-City-Multiplayer,代碼行數:18,代碼來源:Assets.java

示例4: AnimationDrawable

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public AnimationDrawable(SpriteSheet sheet) {
    final int startX = 0;
    final int startY = 0;
    final int frames = 3;

    Array<TextureRegion> tempSpritesUp = AnimationDrawable.grabSprites(sheet, startX, startY, frames);
    Array<TextureRegion> tempSpritesDown = AnimationDrawable.grabSprites(sheet, startX, startY + 2, frames);
    Array<TextureRegion> tempSpritesLeft = AnimationDrawable.grabSprites(sheet, startX, startY + 1, frames, true);
    Array<TextureRegion> tempSpritesRight = AnimationDrawable.grabSprites(sheet, startX, startY + 1, frames);

    AnimationDrawable.addMiddleReversed(tempSpritesUp, false);
    AnimationDrawable.addMiddleReversed(tempSpritesDown, false);
    AnimationDrawable.addMiddleReversed(tempSpritesLeft, false);
    AnimationDrawable.addMiddleReversed(tempSpritesRight, false);

    animations.put(Type.WALK_DOWN, new Animation(1f / (frames * 1.5f), tempSpritesDown));
    animations.put(Type.WALK_UP, new Animation(1f / (frames * 1.5f), tempSpritesUp));
    animations.put(Type.WALK_LEFT, new Animation(1f / (frames * 1.5f), tempSpritesLeft));
    animations.put(Type.WALK_RIGHT, new Animation(1f / (frames * 1.5f), tempSpritesRight));

    for(Animation animation : animations.values()) {
        animation.setPlayMode(Animation.PlayMode.LOOP);
    }

    setAnimationByType(Type.WALK_DOWN); // default animation
}
 
開發者ID:jmrapp1,項目名稱:TerraLegion,代碼行數:27,代碼來源:AnimationDrawable.java

示例5: reverse

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public Animate reverse() {
 final TextureRegion[] srcRegions = _animation.getKeyFrames();
 final int n = srcRegions.length;
 TextureRegion[] newRegions = new TextureRegion[n]; 
 for(int i = 0; i < n; ++i) {
  newRegions[i] = srcRegions[n - 1 - i];
 }
 Animation newAnimation = new Animation(_animation.getFrameDuration(), newRegions);
 newAnimation.setPlayMode(_animation.getPlayMode());
 return Animate.create(newAnimation);
}
 
開發者ID:mingwuyun,項目名稱:cocos2d-java,代碼行數:12,代碼來源:ActionInterval.java

示例6: init

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public void init() {
    CURRENT_STATE = BULLET_STATE.LIVE;
    animation = new Animation(FRAME_DURATION, AssetDoctor.getTextureRegion_ATLAS("bullet_a00"), AssetDoctor.getTextureRegion_ATLAS("bullet_a01"));
    animation.setPlayMode(Animation.PlayMode.LOOP);
    currentSprite = new Sprite(animation.getKeyFrame(elapsedTime));
    resizeSprite(currentSprite);
}
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:8,代碼來源:Bullet.java

示例7: Spatula

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public Spatula(float x, float y) {
    super(x, y);
    FRAME_DURATION = 0.15f;
    SCALE = 2.5f;
    STEP_DIST = 15.0f;
    STEP_COOLDOWN = 0.150f;
    anim = new Animation(FRAME_DURATION, AssetDoctor.getTextureRegion_ATLAS("spatula_00"), AssetDoctor.getTextureRegion_ATLAS("spatula_01"));
    anim.setPlayMode(Animation.PlayMode.LOOP);
    SPRITE = new Sprite(anim.getKeyFrame(0.0f));
    resizeSprite(SPRITE);
    killsound = DS.explosionSound;
}
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:13,代碼來源:Spatula.java

示例8: setupAnimation

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
private void setupAnimation() {
    FRAME_DURATION = 0.1f;
    steps = 0;
    ELAPSED_TIME = 0f;
    anim = new Animation(FRAME_DURATION, AssetDoctor.getTextureRegion_ATLAS("burger_00"), AssetDoctor.getTextureRegion_ATLAS("burger_01"));
    anim.setPlayMode(Animation.PlayMode.LOOP);
    SPRITE = new Sprite(anim.getKeyFrame(0.0f));
    resizeSprite(SPRITE);
}
 
開發者ID:dsaves,項目名稱:Ponytron,代碼行數:10,代碼來源:Burger.java

示例9: loadLogo

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
private void loadLogo() {
    TextureRegion[] regions = new TextureRegion[16];
    for (int i = 0; i < 16; i++) {
        regions[i] = new TextureRegion(new Texture("index" + (i + 1) + ".png"), G.LOGO_WIDTH, G.LOGO_HEIGHT);
    }

    Animation animation = new Animation<>(0.05f, regions);
    animation.setPlayMode(Animation.PlayMode.NORMAL);
    sprites.put("logo", animation);
}
 
開發者ID:DaanVanYperen,項目名稱:odb-little-fortune-planet,代碼行數:11,代碼來源:GameScreenAssetSystem.java

示例10: load

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
public static void load() {

        texture = new Texture(Gdx.files.internal("data/texture.png"));
        texture.setFilter(TextureFilter.Nearest, TextureFilter.Nearest);

        bg = new TextureRegion(texture, 0, 0, 136, 43);
        bg.flip(false, true);

        grass = new TextureRegion(texture, 0, 43, 143, 11);
        grass.flip(false, true);

        birdDown = new TextureRegion(texture, 136, 0, 17, 12);
        birdDown.flip(false, true);

        bird= new TextureRegion(texture,153,0,17,12);
        bird.flip(false,true);

        birdUp=new TextureRegion(texture,170,0,17,12);
        birdUp.flip(false,true);

        TextureRegion[] birds = {birdDown, bird, birdUp};
        birdAnimation=new Animation(0.06f,birds);
        birdAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);

        skullUp =new TextureRegion(texture,192,0,24,14);
        skullDown = new TextureRegion(skullUp);
        skullDown.flip(false,true);

        bar = new TextureRegion(texture, 136, 16, 22, 3);
        bar.flip(false,true);

    }
 
開發者ID:610ksh,項目名稱:MyRoom,代碼行數:33,代碼來源:AssetLoader.java

示例11: loadTargetingAnimations

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
private void loadTargetingAnimations()
{
	Array<TextureRegion> targeterRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/targeter"));
	targetingAnims = new Animation[targeterRegions.size];
	for (int i = 0; i < targetingAnims.length; i++)
	{
		Animation newTargetAnimation = new Animation(1.0f, targeterRegions.get(i));
		newTargetAnimation.setPlayMode(Animation.PlayMode.LOOP);
		targetingAnims[i] = newTargetAnimation;
	}
	
	spotlightAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/spotlight")));
	spotlightAnim.setPlayMode(Animation.PlayMode.LOOP);
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:16,代碼來源:TextureAnimationDrawer.java

示例12: loadProjectileAnimations

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
private void loadProjectileAnimations()
{
	explosionAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("explosion")));
	explosionAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	tankShellAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("tankshell")));
	tankShellAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	bulletAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("bullet")));
	bulletAnim.setPlayMode(Animation.PlayMode.LOOP);
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:15,代碼來源:TextureAnimationDrawer.java

示例13: loadBossAnimations

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
private void loadBossAnimations()
{
	sheriffAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("sheriff")));
	sheriffAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	Array<TextureRegion> jeepRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("jeep"));
	jeepAnims = new Animation[jeepRegions.size];
	for (int i = 0; i < jeepAnims.length; i++)
	{
		Animation newJeepAnimation = new Animation(1.0f, jeepRegions.get(i));
		newJeepAnimation.setPlayMode(Animation.PlayMode.LOOP);
		jeepAnims[i] = newJeepAnimation;
	}
	
	steelHorseAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("steelhorse")));
	steelHorseAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	boostAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("booststeelhorse")));
	boostAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	crashAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("crashsteelhorse")));
	crashAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	pallBearerAnim = new Animation(1.0f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("pallbearer")));
	pallBearerAnim.setPlayMode(Animation.PlayMode.LOOP);
	
	Array<TextureRegion> tankRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("tank"));
	tankAnims = new Animation[tankRegions.size];
	for (int i = 0; i < tankAnims.length; i++)
	{
		Animation newTankAnimation = new Animation(1.0f, tankRegions.get(i));
		newTankAnimation.setPlayMode(Animation.PlayMode.LOOP);
		tankAnims[i] = newTankAnimation;
	}
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:40,代碼來源:TextureAnimationDrawer.java

示例14: setAnimation

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
void setAnimation(String newKey) { //generates animation on the fly from the key loookup and the atlas
    if (!keys.contains(newKey)) {
        throw new NullPointerException();
    }
    currentKey = newKey;
    currentAnimation = new Animation(speeds.get(currentKey), atlases.get(currentKey).getRegions());
    currentAnimation.setPlayMode(Animation.PlayMode.LOOP);
}
 
開發者ID:gforcedev,項目名稱:alexml,代碼行數:9,代碼來源:SubSprite.java

示例15: create

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
@Override
	public void create() {

//		shapeRenderer = new ShapeRenderer();
		
		batch = new SpriteBatch();
		// 初始化遊戲相機
		camera = new OrthographicCamera();
		camera.setToOrtho(false, 800, 480);
		// 初始化UI相機
		uiCamera = new OrthographicCamera();
		// uiCamera.setToOrtho(false, Gdx.graphics.getWidth(),
		// Gdx.graphics.getHeight());

		uiCamera.setToOrtho(false, 800, 480);
		uiCamera.update();

		font = new BitmapFont(Gdx.files.internal("arial.fnt"));

		background = new Texture("background.png");
		ground = new TextureRegion(new Texture("ground.png"));
		ceiling = new TextureRegion(ground);
		ceiling.flip(true, true);

		rock = new TextureRegion(new Texture("rock.png"));
		rockDown = new TextureRegion(rock);
		rockDown.flip(false, true);

		Texture frame1 = new Texture("plane1.png");
		frame1.setFilter(TextureFilter.Linear, TextureFilter.Linear);
		Texture frame2 = new Texture("plane2.png");
		Texture frame3 = new Texture("plane3.png");

		ready = new TextureRegion(new Texture("ready.png"));
		gameOver = new TextureRegion(new Texture("gameover.png"));

		plane = new Animation(0.05f, new TextureRegion(frame1),
				new TextureRegion(frame2), new TextureRegion(frame3),
				new TextureRegion(frame2));
		plane.setPlayMode(PlayMode.LOOP);

		music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
		music.setLooping(true);
		music.play();

		explode = Gdx.audio.newSound(Gdx.files.internal("explode.wav"));

		// 初始化遊戲
		resetWorld();

	}
 
開發者ID:Lowp,項目名稱:FlappyPlane,代碼行數:52,代碼來源:PlaneGame.java


注:本文中的com.badlogic.gdx.graphics.g2d.Animation.setPlayMode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。