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


Java Action类代码示例

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


Action类属于com.badlogic.gdx.scenes.scene2d包,在下文中一共展示了Action类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldParseSpriteView

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Test
@NeedGL
public void shouldParseSpriteView() throws Exception {
    CocoStudioUIEditor editor = new CocoStudioUIEditor(
        Gdx.files.internal("animation/MainScene.json"), null, null, null, null);

    Group group = editor.createGroup();
    Image image = group.findActor("st_2");
    Array<Action> actions = image.getActions();
    assertThat(actions.size, is(1));
    RepeatAction repeatAction = (RepeatAction) actions.get(0);
    ParallelAction parallelAction = (ParallelAction) repeatAction.getAction();
    assertThat(parallelAction.getActions().size, is(3));
    assertThat(parallelAction.getActions(), (Matcher) everyItem(instanceOf(SequenceAction.class)));
    SequenceAction moveAction = (SequenceAction) parallelAction.getActions().get(0);
    SequenceAction scaleAction = (SequenceAction) parallelAction.getActions().get(1);
    assertThat(moveAction.getActions().size, is(4));
    assertThat(moveAction.getActions(), (Matcher) everyItem(instanceOf(MoveToAction.class)));
    assertThat(scaleAction.getActions().size, is(4));
    assertThat(scaleAction.getActions(), (Matcher) everyItem(instanceOf(ScaleToAction.class)));
}
 
开发者ID:varFamily,项目名称:cocos-ui-libgdx,代码行数:22,代码来源:CCSpriteViewTest.java

示例2: show

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Override
public Dialog show(Stage stage, Action action) {
    previousFocussedActor = null;
    previousEscapeActor = null;

    super.show(stage, action);

    if (stage instanceof ControllerMenuStage) {
        previousFocussedActor = ((ControllerMenuStage) stage).getFocussedActor();
        previousEscapeActor = ((ControllerMenuStage) stage).getEscapeActor();

        if (buttonsToAdd.size >= 1)
            ((ControllerMenuStage) stage).setFocussedActor(buttonsToAdd.get(0));

        if (buttonsToAdd.size == 1)
            ((ControllerMenuStage) stage).setEscapeActor(buttonsToAdd.get(0));
    }

    return this;

}
 
开发者ID:MrStahlfelge,项目名称:gdx-controllerutils,代码行数:22,代码来源:ControllerMenuDialog.java

示例3: reactOnClick

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
public void reactOnClick() {
    //Action testAction = Actions.moveBy(10, 15);//sizeBy, moveBy and other action :D
    int xMoveAmount = MathUtils.random(-130, 130);

    Action moveAction = Actions.sequence(
            Actions.moveBy(xMoveAmount, 10, 0.30f, Interpolation.circleOut),
            Actions.moveBy(-xMoveAmount, -10, 0.30f, Interpolation.circle)
    );

    int yGrowAmount = MathUtils.random(-30, 100);

    Action growAction = Actions.sequence(
            Actions.sizeBy(yGrowAmount, 20, 0.2f, Interpolation.circleOut),
            Actions.sizeBy(-yGrowAmount, -20, 0.2f, Interpolation.circle)
    );

    this.addAction(moveAction);
    this.addAction(growAction);

    if(this.getHeight() > 170) {
        this.addAction(Actions.rotateBy(MathUtils.randomSign() * 360, 0.4f));
    }
}
 
开发者ID:BePeGames,项目名称:ClickerGame,代码行数:24,代码来源:Player.java

示例4: show

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Override
public Dialog show(Stage stage, Action action) {
    Dialog dialog = super.show(stage, action);
    
    if (getWidth() > Gdx.graphics.getWidth()) {
        setWidth(Gdx.graphics.getWidth());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    if (getHeight() > Gdx.graphics.getHeight()) {
        setHeight(Gdx.graphics.getHeight());
        setPosition(getWidth() / 2.0f, getHeight() / 2.0f, Align.center);
        setPosition((int) getX(), (int) getY());
    }
    
    resetWidth = getWidth();
    resetHeight = getHeight();
    main.getStage().setScrollFocus(scrollPane);
    return dialog;
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:22,代码来源:DialogWelcome.java

示例5: refreshStyleProperties

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
public void refreshStyleProperties(boolean preserveScroll) {
    if (stylePropertiesTable != null && stylePropertiesScrollPane != null) {
        float scrollY;
        if (preserveScroll) {
            scrollY = stylePropertiesScrollPane.getScrollY();
        } else {
            scrollY = 0;
        }

        stylePropertiesTable.clearChildren();
        addStyleProperties(stylePropertiesTable);

        if (preserveScroll) {
            validate();
            stylePropertiesScrollPane.setSmoothScrolling(false);
            stylePropertiesScrollPane.setScrollY(scrollY);
            stylePropertiesScrollPane.addAction(new SequenceAction(new DelayAction(.1f), new Action() {
                @Override
                public boolean act(float delta) {
                    stylePropertiesScrollPane.setSmoothScrolling(true);
                    return true;
                }
            }));
        }
    }
}
 
开发者ID:raeleus,项目名称:skin-composer,代码行数:27,代码来源:RootTable.java

示例6: getFuelIndicator

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
private Actor getFuelIndicator(float width)
{
    if (this.ship.isInfiniteFuel())
    {
        Label infiniteFuelLabel = new Label("inf", UIManager.skin);
        return infiniteFuelLabel;
    }
    else
    {
        final ProgressBar fuelProgressBar =
            UIManager.getDelimitedProgressBar(this.ship.getMaxFuel(), width);

        fuelProgressBar.addAction(new Action()
        {
            @Override
            public boolean act(float delta)
            {
                fuelProgressBar.setValue(HudScreen.this.ship.getCurrentFuel());
                return false;
            }
        });
        return fuelProgressBar;
    }
}
 
开发者ID:overengineering,项目名称:space-travels-3,代码行数:25,代码来源:HudScreen.java

示例7: show

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Override
public void show(final Stage stage, final Action action) {
    bonuses.clear();
    effects.clear();
    box2d.create();
    minionSprites.clear();
    running = true;
    timer = 0f;
    background = gameAssetService.getRandomBackground();
    for (final Table table : playerViews) {
        table.setVisible(false);
    }
    createPlayerSprites();
    createBlockSprites();
    createMinionSprites();
    super.show(stage, Actions.sequence(action, Actions.run(new Runnable() {
        @Override
        public void run() { // Listening to user input events:
            final InputMultiplexer inputMultiplexer = new InputMultiplexer(stage);
            box2d.initiateControls(inputMultiplexer);
            Gdx.input.setInputProcessor(inputMultiplexer);
        }
    })));
}
 
开发者ID:BialJam,项目名称:M-M,代码行数:25,代码来源:GameController.java

示例8: playMusicBeautifully

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
public void playMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(0);
    if (!usesMusic) {
        disabledMusics.add(music);
    } else {
        music.play();
    }
    music.setLooping(true);
    playingMusics.add(music);
    Action action = new TemporalAction(5f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(percent * volume);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:23,代码来源:SoundManager.java

示例9: stopMusicBeautifully

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
public void stopMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    final float initialVolume = music.getVolume();
    Action action = new TemporalAction(2f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(initialVolume - percent * initialVolume);
        }

        @Override protected void end() {
            music.stop();
            playingMusics.remove(music);
            disabledMusics.remove(music);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:22,代码来源:SoundManager.java

示例10: addActions

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
private void addActions(final Label label, final int i, final int idx, final float speed, final float spinTime, final float endTime, final Runnable callback) {
    label.addAction(new Action() {
        private float totalTime = spinTime + i * endTime;
        @Override public boolean act(float delta) {
            totalTime -= delta;
            label.moveBy(0, -speed * delta);
            boolean finished = totalTime <= 0;
            if (finished) {
                label.setY(-(letters.length() - idx - 1) * lineHeight);
                if (i == labels.size - 1) {
                    callback.run();
                }
            } else {
                while (label.getY() < -letters.length() * lineHeight) {
                    label.setY(label.getY() + letters.length() * lineHeight);
                }
            }
            return finished;
        }
    });
}
 
开发者ID:ratrecommends,项目名称:dice-heroes,代码行数:22,代码来源:StringSpin.java

示例11: addItems

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
/**
 * Ajoute des items actifs à l'interface.
 */
public void addItems() {
    skin.add("itemCounter", new LabelStyle(skin.getFont("itemCounter"), null));

    activeItems = new HashMap<Sprite, Integer>();
    itemsGroup = new Table();
    itemsGroup.addAction(new Action() {
        @Override
        public boolean act(float delta) {
            itemsGroup.clearChildren();

            for (Map.Entry<Sprite, Integer> entry : activeItems.entrySet()) {
                itemImage = new Image(entry.getKey());
                itemsGroup.add(itemImage).padRight(Gdx.graphics.getWidth() / 50);
                itemCounter = new Label(entry.getValue().toString(), skin, "itemCounter");
                itemsGroup.add(itemCounter).padRight(Gdx.graphics.getWidth() / 15);
            }

            return false;
        }
    });

    itemsContainer.setActor(itemsGroup);
}
 
开发者ID:naomiHauret,项目名称:OdysseeDesMaths,代码行数:27,代码来源:MiniGameUI.java

示例12: getDefaultViewShowingActionProvider

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
private ActionProvider getDefaultViewShowingActionProvider() {
    return new ActionProvider() {
        @Override
        public Action provideAction(final ViewController forController, final ViewController previousController) {
            if (musicService.getCurrentTheme() == null && GdxArrays.isNotEmpty(forController.getThemes())) {
                final Music currentTheme = forController.getThemes().random();
                return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                        Actions.run(CommonActionRunnables.getMusicThemeSetterRunnable(musicService, currentTheme)),
                        Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())),
                        MusicFadingAction.fadeIn(currentTheme, MusicService.DEFAULT_THEME_FADING_TIME,
                                musicService.getMusicVolume()));
            }
            return Actions.sequence(Actions.alpha(0f), Actions.fadeIn(DEFAULT_FADING_TIME),
                    Actions.run(CommonActionRunnables.getInputSetterRunnable(forController.getStage())));
        }
    };
}
 
开发者ID:gdx-libs,项目名称:gdx-autumn-mvc,代码行数:18,代码来源:InterfaceService.java

示例13: setView

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
/** @param view will be set as the current view after view transition. Current screen (if any exists) will receive a
 *            {@link AbstractLmlView#hide()} call. The new screen will be resized using
 *            {@link AbstractLmlView#resize(int, int, boolean)} and then will receive a
 *            {@link AbstractLmlView#show()} call.
 * @param doAfterHide will be executed after the current view is fully hidden. Is never executed if there was no
 *            current view.
 * @see #getViewShowingAction(AbstractLmlView)
 * @see #getViewHidingAction(AbstractLmlView) */
public void setView(final AbstractLmlView view, final Action doAfterHide) {
    if (currentView != null) {
        viewChangeRunnable.setView(view);
        Gdx.input.setInputProcessor(null);
        currentView.hide();
        final Action hideAction = doAfterHide == null
                ? Actions.sequence(getViewHidingAction(currentView), Actions.run(viewChangeRunnable))
                : Actions.sequence(getViewHidingAction(currentView), doAfterHide, Actions.run(viewChangeRunnable));
        currentView.getStage().addAction(hideAction);
    } else {
        currentView = view;
        currentView.resize(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), isCenteringCameraOnResize());
        Gdx.input.setInputProcessor(currentView.getStage());
        currentView.show();
        currentView.getStage().addAction(getViewShowingAction(view));
    }
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:26,代码来源:LmlApplicationListener.java

示例14: setLocale

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
/** Also available as "setLocale" action in LML views. Will extract locale from actor's ID.
 *
 * @param locale will be set as the current application's locale. If is not equal to the current locale, will hide
 *            current view, reload all referenced {@link com.badlogic.gdx.utils.I18NBundle i18n bundles}, recreate
 *            all views and reshow the current view. */
public void setLocale(final Locale locale) {
    if (!localePreference.isCurrent(locale)) {
        setView(getCurrentView(), new Action() {
            private boolean reloaded = false;

            @Override
            public boolean act(final float delta) {
                if (!reloaded) {
                    reloaded = true;
                    localePreference.setLocale(locale);
                    localePreference.save();
                    reloadViews();
                }
                return true;
            }
        });
    }
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:24,代码来源:LmlApplication.java

示例15: process

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Override
protected void process(final LmlParser parser, final LmlTag tag, final TabbedPane tabbedPane,
        final String rawAttributeData) {
    if (tag instanceof TabbedPaneLmlTag) {
        @SuppressWarnings("unchecked") final ActorConsumer<Action, Tab> action = (ActorConsumer<Action, Tab>) parser
                .parseAction(rawAttributeData, MOCK_UP_TAB);
        if (action == null) {
            parser.throwErrorIfStrict(
                    "Unable to find action consuming Tab and returning Action for ID: " + rawAttributeData);
            return;
        }
        ((TabbedPaneLmlTag) tag).setShowActionProvider(action);
    } else {
        parser.throwErrorIfStrict(
                "Unexpected tag type for tabbed pane tag. Expected: TabbedPaneLmlTag, got: " + tag.getClass());
    }
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:18,代码来源:TabShowingActionLmlAttribute.java


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