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


Java Animation.isAnimationFinished方法代碼示例

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


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

示例1: drawCowboy

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
/**
 * Draw Cowboy State and Animation
 */
private void drawCowboy(){
    int i=0;
    for(Cowboy cowboy : world.getCowboys()){
        Animation animation;
        if(i==1) { //right side cowboy
            animation = getAnimation(cowboy.getState(), "left");
            if(animation == null)
                currentFrame = cowboyIdleRight;
        }else{     //left side cowboy
            animation = getAnimation(cowboy.getState(), "right");
            if(animation == null)
                currentFrame = cowboyIdleLeft;
        }

        if (animation != null) {
            if (flagFinishShot && cowboy.getState().equals(Cowboy.State.WIN) && cowboy.getCowboyId() == winId) {
                winStateTime += Gdx.graphics.getDeltaTime();
                currentFrame = animation.getKeyFrame(winStateTime, true);
            } else {
                if (animation.isAnimationFinished(stateTime)) {
                    if (cowboy.isFlagHit() && cowboy.getCowboyId() == winId) {
                        cowboy.setState(Cowboy.State.WIN);
                        flagFinishShot = true;
                        stateTime = 0;
                    }else {
                        currentFrame = animation.getKeyFrame(stateTime);
                    }
                } else {
                    stateTime += Gdx.graphics.getDeltaTime();
                    currentFrame = animation.getKeyFrame(stateTime, true);
                }
            }
        }

        spriteBatch.draw(currentFrame, cowboy.getPosition().x * ppuX, cowboy.getPosition().y * ppuY,
                cowboy.SIZE * ppuX, cowboy.SIZE * ppuY);
        i++;
    }
}
 
開發者ID:fr3ndyl33,項目名稱:123Dor,代碼行數:43,代碼來源:WorldRenderer.java

示例2: drawCowboy

import com.badlogic.gdx.graphics.g2d.Animation; //導入方法依賴的package包/類
/**
 * Draw Cowboy State and Animation
 */
private void drawCowboy(){
    int i=0;
    for(Cowboy cowboy : world.getCowboys()){
        Animation animation;
        if(i==1) { //right side cowboy
            animation = getAnimation(cowboy.getState(), "left");
            if(animation == null) {
                if(cowboy.getState().equals(Cowboy.State.HIDE))
                    currentFrame = cowboyHideRight;
                else
                    currentFrame = cowboyIdleRight;
            }
        }else{     //left side cowboy
            animation = getAnimation(cowboy.getState(), "right");
            if(animation == null)
                if(cowboy.getState().equals(Cowboy.State.HIDE))
                    currentFrame = cowboyHideLeft;
                else
                    currentFrame = cowboyIdleLeft;
        }

        if (animation != null) {
            if (flagFinishShot && cowboy.getState().equals(Cowboy.State.WIN) && cowboy.getCowboyId() == winId) {
                winStateTime += Gdx.graphics.getDeltaTime();
                currentFrame = animation.getKeyFrame(winStateTime, true);
            } else {
                if (animation.isAnimationFinished(stateTime)) {
                    if (cowboy.isFlagHit() && cowboy.getCowboyId() == winId) {
                        cowboy.setState(Cowboy.State.WIN);
                        flagFinishShot = true;
                        stateTime = 0;
                    }else {
                        currentFrame = animation.getKeyFrame(stateTime);
                    }
                } else {
                    stateTime += Gdx.graphics.getDeltaTime();
                    currentFrame = animation.getKeyFrame(stateTime, true);
                }
            }
        }

        spriteBatch.draw(currentFrame, cowboy.getPosition().x * ppuX, cowboy.getPosition().y * ppuY,
                cowboy.getSize() * ppuX, cowboy.getSize() * ppuY);
        i++;
    }
}
 
開發者ID:fr3ndyl33,項目名稱:123Dor,代碼行數:50,代碼來源:GameScreen.java


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