本文整理汇总了Java中net.mostlyoriginal.game.component.ui.Button类的典型用法代码示例。如果您正苦于以下问题:Java Button类的具体用法?Java Button怎么用?Java Button使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Button类属于net.mostlyoriginal.game.component.ui包,在下文中一共展示了Button类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createConstructionButtons
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void createConstructionButtons() {
int index = 0;
for (ShipComponent.Type structure : ShipComponent.Type.values()) {
if (structure.buildable) {
int x = G.SCREEN_WIDTH + MARGIN_RIGHT - (index + 1) * 18;
int y = 7;
final Entity button = efs.createButton(x, y, 15, 15, "btn-construct", new ToolSelectButton(structure), null);
constructionButton.put(structure, button);
Button button1 = mButton.get(button);
button1.color = Color.WHITE;
button1.hint = structure.label;
button1.hideIfDisabled =true;
button1.transientIcon = new SafeEntityReference(new EntityBuilder(world).with(
new Pos(x + 4, y + 5),
new Anim(structure.animId),
new Renderable(4000)).build());
// add icon over button. @todo merge with button logic.
index++;
}
}
}
示例2: createButton
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
public Entity createButton(int x, int y, int width, int height, String animPrefix, ButtonListener listener, String hint) {
Entity e = new DynastyEntityBuilder(world)
.with(new Bounds(0, 0, width, height),
new Anim(),
new Button(animPrefix, listener, hint),
new Clickable())
.with(Pos.class, Renderable.class, Tint.class, Scale.class)
.build();
mPos.get(e).xy.set(x, y);
mScale.get(e).scale = G.ZOOM;
mRenderable.get(e).layer = 1100;
return e;
}
示例3: updateAnim
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void updateAnim(Entity e) {
String id = getNewAnimId(e);
if (id != null) {
final Button button = mButton.get(e);
boolean automaticDisable = button.hideIfDisabled && !button.listener.enabled();
if (automaticDisable) {
id = null;
}
// quick hack to hide icons when button is hidden. @todo cleanup.
if (button.transientIcon != NO_ENTITY) {
int bute = button.transientIcon;
if ((id != null) && mInvisible.has(bute)) {
mInvisible.remove(bute);
}
if ((id == null) && !mInvisible.has(bute)) {
mInvisible.create(bute);
}
}
if (mAnim.has(e)) {
mAnim.get(e).id = id;
} else if (mColor.has(e)) {
// @todo fix this hack! XD
mColor.get(e).set(GdxUtil.asColor(id));
}
}
}
示例4: triggerButton
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void triggerButton(Button button) {
if (button.listener.enabled() && globalButtonCooldown <= 0 && !button.manualDisable) {
if (!button.autoclick) assetSystem.playSfx("snd-click");
// prevent spamming by accident.
if (!button.autoclick) globalButtonCooldown = 0.1f;
button.listener.run();
}
}
示例5: updateAnim
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void updateAnim(Entity e) {
String id = getNewAnimId(e);
if (id != null) {
final Button button = mButton.get(e);
boolean automaticDisable = button.hideIfDisabled && !button.listener.enabled();
if (automaticDisable) {
id = null;
}
// quick hack to hide icons when button is hidden. @todo cleanup.
if ( button.transientIcon != null ) {
if (button.transientIcon.isActive()) {
Entity bute = button.transientIcon.get();
if ((id != null) && mInvisible.has(bute)) {
bute.edit().remove(Invisible.class);
}
if ((id == null) && !mInvisible.has(bute)) {
bute.edit().add(new Invisible());
}
}
}
if (mAnim.has(e)) {
mAnim.get(e).id = id;
} else if (mColor.has(e)) {
// @todo fix this hack! XD
mColor.get(e).setHex(id);
}
}
}
示例6: triggerButton
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void triggerButton(Button button) {
if (button.listener.enabled() && globalButtonCooldown <= 0 && !button.manualDisable ) {
if ( !button.autoclick && assetSystem.getSfx("snd-click") != null ) assetSystem.playSfx("snd-click");
// prevent spamming by accident.
if ( !button.autoclick ) globalButtonCooldown = 0.1f;
button.listener.run();
}
}
示例7: createButton
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
public Entity createButton(int x, int y, int width, int height, String animPrefix, ButtonListener listener, String hint) {
return new EntityBuilder(world)
.with(new Pos(x, y),
new Bounds(0, 0, width, height),
new Anim(),
new Color(),
new Renderable(1100),
new Button(animPrefix, listener, hint),
new Clickable()).build();
}
示例8: spawnCollectible
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
public void spawnCollectible(float x, float y, InventorySystem.Resource resource) {
final Entity cursor = tagManager.getEntity("cursor");
assetSystem.playSfx("snd-squish");
CollectCollectible listener = new CollectCollectible(resource);
Button button = new Button(listener);
button.autoclick = true;
button.autoclickCooldown = 0.8f;
Physics physics = new Physics();
physics.vx = MathUtils.random(-15f, 15f);
physics.vy = MathUtils.random(-15f, 15f);
Homing homing = new Homing(new SafeEntityReference(cursor));
homing.maxDistance = 40;
homing.speedFactor = 0.5f;
listener.entity =
new EntityBuilder(world).
with(
new Pos(x, y),
physics,
new Clickable(),
new ColorAnimation(GdxUtil.convert(Color.CLEAR), GdxUtil.convert(Color.WHITE), GdxUtil.convert(Interpolation.linear), 1f, 1f),
homing,
new Clamped(0, 0, G.SCREEN_WIDTH, G.SCREEN_HEIGHT),
new Anim(resource.pickupAnimId),
new Renderable(10000),
new Bounds(0 - 4, 0 - 4, 8 + 4, 6 + 4), button).build();
}
示例9: updateAnim
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void updateAnim(Entity e) {
String id = getNewAnimId(e);
if (id != null) {
final Button button = mButton.get(e);
boolean automaticDisable = button.hideIfDisabled && !button.listener.enabled();
if (automaticDisable) {
id = null;
}
// quick hack to hide icons when button is hidden. @todo cleanup.
if ( button.transientIcon != null ) {
if (button.transientIcon.isActive()) {
Entity bute = button.transientIcon.get();
if ((id != null) && mInvisible.has(bute)) {
bute.edit().remove(Invisible.class);
}
if ((id == null) && !mInvisible.has(bute)) {
bute.edit().add(new Invisible());
}
}
}
if (mAnim.has(e)) {
mAnim.get(e).id = id;
} else if (mColor.has(e)) {
// @todo fix this hack! XD
mColor.get(e).set(GdxUtil.asColor(id));
}
}
}
示例10: triggerButton
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private void triggerButton(Button button) {
if (button.listener.enabled() && globalButtonCooldown <= 0 && !button.manualDisable ) {
if ( !button.autoclick) assetSystem.playSfx("snd-click");
// prevent spamming by accident.
if ( !button.autoclick ) globalButtonCooldown = 0.1f;
button.listener.run();
}
}
示例11: ButtonSystem
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
public ButtonSystem() {
super(Aspect.all(Button.class, Clickable.class, Bounds.class).one(Anim.class, Label.class));
}
示例12: getNewAnimId
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private String getNewAnimId(Entity e) {
final Clickable clickable = mClickable.get(e);
final Button button = mButton.get(e);
if (button.autoclick) {
button.autoclickCooldown -= world.delta;
}
// disable the button temporarily after use to avoid trouble.
if (button.cooldown >= 0) {
button.cooldown -= world.delta;
return button.animClicked;
}
// gray out disabled items. @todo separate.
boolean active = button.listener.enabled() && !button.manualDisable;
if (mColor.has(e)) {
Color color = mColor.get(e).color;
color.r = button.color.r * (active ? 1f : 0.5f);
color.g = button.color.g * (active ? 1f : 0.5f);
color.b = button.color.b * (active ? 1f : 0.5f);
color.a = button.color.a;
if (button.transientIcon != NO_ENTITY) {
final int iconEntity = button.transientIcon;
if (mColor.has(iconEntity)) {
mColor.get(iconEntity).set(color);
}
}
if (!active) {
return button.animDefault;
}
}
switch (clickable.state) {
case HOVER:
if (button.autoclick && button.autoclickCooldown <= 0) {
return click(button);
}
hintlabel.text = button.hint;
return button.animHover;
case CLICKED:
if (!button.autoclick) return click(button);
default:
return button.animDefault;
}
}
示例13: click
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private String click(Button button) {
button.cooldown = COOLDOWN_AFTER_BUTTON_CLICK;
triggerButton(button);
return button.animClicked;
}
示例14: ButtonSystem
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public ButtonSystem() {
super(Aspect.getAspectForAll(Button.class, Clickable.class, Bounds.class).one(Anim.class, Label.class));
}
示例15: getNewAnimId
import net.mostlyoriginal.game.component.ui.Button; //导入依赖的package包/类
private String getNewAnimId(Entity e) {
final Clickable clickable = mClickable.get(e);
final Button button = mButton.get(e);
if ( button.autoclick ) {
button.autoclickCooldown -= world.delta;
}
// disable the button temporarily after use to avoid trouble.
if (button.cooldown >= 0) {
button.cooldown -= world.delta;
return button.animClicked;
}
// gray out disabled items. @todo separate.
boolean active = button.listener.enabled() && !button.manualDisable;
if (mColor.has(e)) {
Color color = mColor.get(e);
color.r = button.color.r * (active ? 1f : 0.5f);
color.g = button.color.g * (active ? 1f : 0.5f);
color.b = button.color.b * (active ? 1f : 0.5f);
color.a = button.color.a;
if ( button.transientIcon != null && button.transientIcon.isActive() )
{
final Entity iconEntity = button.transientIcon.get();
if ( mColor.has(iconEntity )) {
mColor.get(iconEntity).set(color);
}
}
if (!active) {
return button.animDefault;
}
}
switch (clickable.state) {
case HOVER:
if (button.autoclick && button.autoclickCooldown <= 0) {
return click(button);
}
hintlabel.text = button.hint;
return button.animHover;
case CLICKED_LEFT:
if ( !button.autoclick ) return click(button);
default:
return button.animDefault;
}
}