• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Action类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: 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).setHideActionProvider(action);
    } else {
        parser.throwErrorIfStrict(
                "Unexpected tag type for tabbed pane tag. Expected: TabbedPaneLmlTag, got: " + tag.getClass());
    }
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:18,代码来源:TabHidingActionLmlAttribute.java


示例17: act

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
public boolean act (float delta) {
	if (complete) return true;
	complete = true;
	Pool pool = getPool();
	setPool(null); // Ensure this action can't be returned to the pool while executing.
	try {
		Array<Action> actions = this.actions;
		for (int i = 0, n = actions.size; i < n && actor != null; i++) {
			if (!actions.get(i).act(delta)) complete = false;
			if (actor == null) return true; // This action was removed.
		}
		return complete;
	} finally {
		setPool(pool);
	}
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:17,代码来源:ParallelAction.java


示例18: show

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
/** {@link #pack() Packs} the dialog and adds it to the stage with custom action which can be null for instant show */
public Dialog show (Stage stage, Action action) {
	clearActions();
	removeCaptureListener(ignoreTouchDown);

	previousKeyboardFocus = null;
	Actor actor = stage.getKeyboardFocus();
	if (actor != null && !actor.isDescendantOf(this)) previousKeyboardFocus = actor;

	previousScrollFocus = null;
	actor = stage.getScrollFocus();
	if (actor != null && !actor.isDescendantOf(this)) previousScrollFocus = actor;

	pack();
	stage.addActor(this);
	stage.setKeyboardFocus(this);
	stage.setScrollFocus(this);
	if (action != null) addAction(action);

	return this;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:Dialog.java


示例19: hide

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
/** Hides the dialog with the given action and then removes it from the stage. */
public void hide (Action action) {
	Stage stage = getStage();
	if (stage != null) {
		removeListener(focusListener);
		if (previousKeyboardFocus != null && previousKeyboardFocus.getStage() == null) previousKeyboardFocus = null;
		Actor actor = stage.getKeyboardFocus();
		if (actor == null || actor.isDescendantOf(this)) stage.setKeyboardFocus(previousKeyboardFocus);

		if (previousScrollFocus != null && previousScrollFocus.getStage() == null) previousScrollFocus = null;
		actor = stage.getScrollFocus();
		if (actor == null || actor.isDescendantOf(this)) stage.setScrollFocus(previousScrollFocus);
	}
	if (action != null) {
		addCaptureListener(ignoreTouchDown);
		addAction(sequence(action, Actions.removeListener(ignoreTouchDown, true), Actions.removeActor()));
	} else
		remove();
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:Dialog.java


示例20: create

import com.badlogic.gdx.scenes.scene2d.Action; //导入依赖的package包/类
@Override
public void create () {
	stage = new Stage();

	Action complexAction = forever(sequence(parallel(rotateBy(180, 2), scaleTo(1.4f, 1.4f, 2), alpha(0.7f, 2)),
		parallel(rotateBy(180, 2), scaleTo(1.0f, 1.0f, 2), alpha(1.0f, 2))));

	texture = new Texture(Gdx.files.internal("data/badlogic.jpg"), false);
	texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);

	final Image img1 = new Image(new TextureRegion(texture));
	img1.setSize(100, 100);
	img1.setOrigin(50, 50);
	img1.setPosition(50, 50);

	final Image img2 = new Image(new TextureRegion(texture));
	img2.setSize(50, 50);
	img2.setOrigin(50, 50);
	img2.setPosition(150, 150);

	stage.addActor(img1);
	stage.addActor(img2);

	img1.addAction(complexAction);
	// img2.action(complexAction.copy());
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:27,代码来源:ComplexActionTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CloseableReference类代码示例发布时间:2022-05-20
下一篇:
Java FeatureInfo类代码示例发布时间:2022-05-20
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap