Java Code Examples for com.badlogic.gdx.scenes.scene2d.Actor#addAction()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Actor#addAction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PageView.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
public void nextView() {
    Gdx.app.debug("PageView", "Change to next view");
    SnapshotArray<Actor> children = this.getChildren();
    if (children.get(children.size - 1).getX() <= 0) {
        Gdx.app.debug("PageView", "Already last one, can't move to next.");
        return;
    }
    Actor[] actors = children.begin();
    float width = this.getWidth();
    for (Actor actor : actors) {
        if (actor != null) {
            actor.addAction(Actions.moveTo(actor.getX() - width, 0, 0.5f));
        }
    }
    children.end();
}
 
Example 2
Source File: PageView.java    From cocos-ui-libgdx with Apache License 2.0 6 votes vote down vote up
public void previousView() {
    Gdx.app.debug("PageView", "Change to previous view");
    SnapshotArray<Actor> children = this.getChildren();
    if (children.get(0).getX() >= 0) {
        Gdx.app.debug("PageView", "Already first one, can't move to previous.");
        return;
    }
    float width = this.getWidth();
    Actor[] actors = children.begin();
    for (Actor actor : actors) {
        if (actor != null) {
            actor.addAction(Actions.moveTo(actor.getX() + width, 0, 0.5f));
        }
    }
    children.end();
}
 
Example 3
Source File: DelegateInputEventsLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, LmlTag tag, final Actor actor, String rawAttributeData) {
    final String id = parser.parseString(rawAttributeData);
    // Post for one frame to let the layout to be fully parsed (target actor may be parsed after this attribute).
    actor.addAction(Actions.run(new Runnable() {
        @Override
        public void run() {
            final Actor targetActor = parser.getActorsMappedByIds().get(id);
            if (targetActor == null) {
                parser.throwErrorIfStrict("Cannot find actor for ID: " + id);
                return;
            }

            actor.addListener(new EventListener() {
                @Override
                public boolean handle(Event event) {
                    if (event instanceof InputEvent) {
                        return targetActor.notify(event, false);
                    }
                    return false;
                }
            });
        }
    }));
}
 
Example 4
Source File: OriginLmlAttribute.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final int origin = LmlUtilities.parseAlignment(parser, actor, rawAttributeData);
    // Simple trick to make this attribute applied after actor is laid out (likely)
    actor.addAction(ActionsExt.post(Actions.run(new Runnable() {
        @Override
        public void run() {
            actor.setOrigin(origin);
        }
    })));
}
 
Example 5
Source File: ViewController.java    From dice-heroes with GNU General Public License v3.0 5 votes vote down vote up
public static void blink(final Actor image, final float from, final float to) {
    image.addAction(Actions.sequence(
        Actions.alpha(to, 0.5f),
        Actions.alpha(from, 0.5f),
        Actions.run(new Runnable() {
            @Override public void run() {
                blink(image, from, to);
            }
        })
    ));
}
 
Example 6
Source File: OriginLmlAttribute.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    final int origin = LmlUtilities.parseAlignment(parser, actor, rawAttributeData);
    // Simple trick to make this attribute applied after actor is laid out (likely)
    actor.addAction(ActionsExt.post(Actions.run(new Runnable() {
        @Override
        public void run() {
            actor.setOrigin(origin);
        }
    })));
}
 
Example 7
Source File: InitialUpdateCheckService.java    From gdx-texture-packer-gui with Apache License 2.0 4 votes vote down vote up
private void showUpdateNotification(VersionData version) {
    // Check if current version should be ignored
    try {
        String ignoreVersionSt = prefs.getString(PREF_KEY_IGNORE_NOTIFICATION, null);
        if (ignoreVersionSt != null) {
            Version ignoreVersion = new Version(ignoreVersionSt);
            if (ignoreVersion.equals(version.version)) {
                Gdx.app.log(TAG, "Update is available " + version.version + ", but notification is muted for that version.");
                return;
            }
        }
    } catch (IllegalArgumentException e) {
        // If something went wrong during ignore version checking, we simply ignore it
        e.printStackTrace();
    }

    LmlParser parser = interfaceService.getParser();
    ToastActions toastActions = new ToastActions(prefs, version);

    parser.getData().addArgument("newVersionCode", version.getVersion().toString());
    parser.getData().addArgument("newVersionUrl", version.getUrl());
    parser.getData().addActionContainer(ToastActions.class.getSimpleName(), toastActions);
    Group content = (Group)parser.parseTemplate(
            Gdx.files.internal("lml/toastNewVersionAvailable.lml")).first();
    parser.getData().removeActionContainer(ToastActions.class.getSimpleName());

    Actor imgLogo = content.findActor("imgLogo");
    imgLogo.addAction(Actions.forever(Actions.sequence(
            Actions.delay(0.5f),
            Actions.scaleTo(0.8f, 1.2f, 0.1f, Interpolation.exp10Out),
            Actions.scaleTo(1.1f, 0.9f, 0.1f, Interpolation.exp10Out),
            Actions.scaleTo(1.0f, 1.0f, 0.5f, Interpolation.exp10Out)
    )));

    ToastTable toastTable = new ToastTable();
    toastTable.add(content).grow();
    toastActions.setToastTable(toastTable);

    eventDispatcher.postEvent(new ShowToastEvent()
            .content(toastTable)
            .duration(ShowToastEvent.DURATION_INDEFINITELY));
}
 
Example 8
Source File: PieMenu.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
public void show(InteractiveActor a, float x, float y) {
	setVisible(true);
	this.x = x;
	this.y = y;
	iActor = a;

	// DRAW TARGET DESCRIPTION
	desc = iActor.getDesc();

	if (desc != null) {

		if (desc.charAt(0) == I18N.PREFIX)
			desc = sceneScreen.getWorld().getI18N().getString(desc.substring(1));

		layout.setText(font, desc);
	}

	Actor rightButton;

	if (a.getVerb("talkto") != null) {
		talktoButton.setVisible(true);
		pickupButton.setVisible(false);
		rightButton = talktoButton;
	} else {
		talktoButton.setVisible(false);
		pickupButton.setVisible(true);
		rightButton = pickupButton;
	}

	float margin = DPIUtils.getMarginSize();

	// FITS TO SCREEN
	if (x < lookatButton.getWidth() + margin)
		this.x = lookatButton.getWidth() + margin;
	else if (x > viewportWidth - lookatButton.getWidth() - margin)
		this.x = viewportWidth - lookatButton.getWidth() - margin;

	if (y < margin)
		this.y = margin;
	else if (y > viewportHeight - lookatButton.getHeight() - margin)
		this.y = viewportHeight - lookatButton.getHeight() - margin;

	// lookatButton.setPosition(this.x - lookatButton.getWidth() - margin / 2,
	// this.y + margin);
	lookatButton.setPosition(this.x - lookatButton.getWidth() / 2, this.y - lookatButton.getHeight() / 2);
	lookatButton.addAction(Actions.moveTo(this.x - lookatButton.getWidth() - margin / 2, this.y + margin, .1f));

	// rightButton.setPosition(this.x + margin / 2, this.y + margin);
	rightButton.setPosition(this.x - lookatButton.getWidth() / 2, this.y - lookatButton.getHeight() / 2);
	rightButton.addAction(Actions.moveTo(this.x + margin / 2, this.y + margin, .1f));

}
 
Example 9
Source File: EditableSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
protected void onShow(Actor selectBoxList, boolean below) {
	selectBoxList.getColor().a = 0;
	selectBoxList.addAction(fadeIn(0.3f, Interpolation.fade));
}
 
Example 10
Source File: FilteredSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
protected void onShow(Actor selectBoxList, boolean below) {
	selectBoxList.getColor().a = 0;
	selectBoxList.addAction(fadeIn(0.3f, Interpolation.fade));
}
 
Example 11
Source File: FilteredSelectBox.java    From bladecoder-adventure-engine with Apache License 2.0 4 votes vote down vote up
protected void onHide(Actor selectBoxList) {
	selectBoxList.getColor().a = 1;
	selectBoxList.addAction(sequence(fadeOut(0.15f, Interpolation.fade), removeActor()));
}