本文整理汇总了Java中com.badlogic.gdx.scenes.scene2d.ui.Touchpad.TouchpadStyle方法的典型用法代码示例。如果您正苦于以下问题:Java Touchpad.TouchpadStyle方法的具体用法?Java Touchpad.TouchpadStyle怎么用?Java Touchpad.TouchpadStyle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.scenes.scene2d.ui.Touchpad
的用法示例。
在下文中一共展示了Touchpad.TouchpadStyle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setupUi
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
protected void setupUi() {
stage = new Stage(uiViewport, batch);
Gdx.input.setInputProcessor(stage);
if(Gdx.app.getType() != Application.ApplicationType.Android && Gdx.app.getType() != Application.ApplicationType.iOS) {
return;
}
touchpadSkin = new Skin();
touchpadSkin.add("touchBackground", new Texture("data/touchBackground.png"));
touchpadSkin.add("touchKnob", new Texture("data/touchKnob.png"));
touchpadStyle = new Touchpad.TouchpadStyle();
touchBackground = touchpadSkin.getDrawable("touchBackground");
touchKnob = touchpadSkin.getDrawable("touchKnob");
touchpadStyle.background = touchBackground;
touchpadStyle.knob = touchKnob;
touchpad = new Touchpad(10, touchpadStyle);
touchpad.setBounds(15, 15, 200, 200);
stage.addActor(touchpad);
}
示例2: initTouchpad
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
private void initTouchpad() {
// TODO: use uiskin.json
// Skin touchpadSkin = new Skin(Gdx.files.internal("data/uiskin.json"));
Skin touchpadSkin = new Skin();
touchpadSkin.add("touchBackground", assetService.getTexture(TOUCH_BACKGROUND));
touchpadSkin.add("touchKnob", assetService.getTexture(TOUCH_KNOB));
Touchpad.TouchpadStyle style = new Touchpad.TouchpadStyle();
style.background = touchpadSkin.getDrawable("touchBackground");
style.knob = touchpadSkin.getDrawable("touchKnob");
style.knob.setMinHeight(TOUCHPAD_SIZE / 2);
style.knob.setMinWidth(TOUCHPAD_SIZE / 2);
touchPad = new Touchpad(15, style);
touchPad.setBounds(TOUCHPAD_MARGIN, TOUCHPAD_MARGIN, TOUCHPAD_SIZE, TOUCHPAD_SIZE);
addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
super.clicked(event, x, y);
}
});
NoClickZone padZone = new NoClickZone(touchPad, NO_CLICK_MARGIN);
addActor(padZone);
touchpadSkin.add("touchButton", assetService.getTexture(TOUCH_KNOB));
button = new GamepadButton(touchpadSkin.getDrawable("touchButton"));
button.setSize(BUTTON_SIZE, BUTTON_SIZE);
NoClickZone buttonZone = new NoClickZone(button, NO_CLICK_MARGIN);
addActor(buttonZone);
}
示例3: touchPadConf
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public void touchPadConf() {
touchpadSkin = new Skin();
touchpadSkin.add("touchpadBackground", new Texture("touchpadBackground.png"));
touchpadSkin.add("touchKnob", new Texture("touchKnob.png"));
touchpadStyle = new Touchpad.TouchpadStyle();
touchpadBackground = touchpadSkin.getDrawable("touchpadBackground");
touchpadKnob = touchpadSkin.getDrawable("touchKnob");
touchpadStyle.background = touchpadBackground;
touchpadStyle.knob = touchpadKnob;
touchpad = new Touchpad(20, touchpadStyle);
touchpad.setBounds(15, 15 ,150, 150);
}
示例4: init
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
@Override
public void init(StageControl stage) {
config = new ConfigTouch();
config.load();
// Touchpad
float x = Gdx.graphics.getWidth() * (100f / 2560);
float y = Gdx.graphics.getHeight() * (100f / 1440);
float touchpadWidth = Gdx.graphics.getWidth() * (250f / 2560);
float touchpadHeight = Gdx.graphics.getHeight() * (250f / 1440);
Skin touchpadSkin = new Skin();
touchpadSkin.add("background", new Texture("image/touchpad-background.png"));
touchpadSkin.add("knob",
TextureUtil.resizeTexture("image/touchpad-knob.png", touchpadWidth / 2,
touchpadHeight / 2));
Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
touchpadStyle.background = touchpadSkin.getDrawable("background");
touchpadStyle.knob = touchpadSkin.getDrawable("knob");
touchpad = new Touchpad(10, touchpadStyle);
touchpad.setBounds(x, y, touchpadWidth, touchpadHeight);
stage.addActor(touchpad);
// A Button
float buttonWidth = touchpadWidth / 2;
float buttonHeight = touchpadHeight / 2;
Skin buttonSkin = new Skin();
buttonSkin.add("up",
TextureUtil.resizeTexture("image/button-up.png", buttonWidth, buttonHeight));
buttonSkin.add("down",
TextureUtil.resizeTexture("image/button-down.png", buttonWidth, buttonHeight));
TextButton.TextButtonStyle buttonStyle = new TextButton.TextButtonStyle();
buttonStyle.up = buttonSkin.getDrawable("up");
buttonStyle.down = buttonSkin.getDrawable("down");
buttonStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
buttonA = new TextButton("A", buttonStyle);
buttonA.setPosition(Gdx.graphics.getWidth() - x - buttonWidth, y + buttonHeight);
stage.addActor(buttonA);
// B Button
buttonB = new TextButton("B", buttonStyle);
buttonB.setPosition(Gdx.graphics.getWidth() - x - 2 * buttonWidth, y);
stage.addActor(buttonB);
// X Button
buttonX = new TextButton("X", buttonStyle);
buttonX.setPosition(buttonA.getX() - buttonWidth, buttonA.getY() + buttonHeight);
stage.addActor(buttonX);
// Y Button
buttonY = new TextButton("Y", buttonStyle);
buttonY.setPosition(buttonB.getX() - buttonWidth, buttonB.getY() + buttonHeight);
stage.addActor(buttonY);
// Home Button
buttonHome = new TextButton("H", buttonStyle);
buttonHome.setPosition(Gdx.graphics.getWidth() / 2 - buttonWidth / 2, 10);
stage.addActor(buttonHome);
// Minus Button
buttonMinus = new TextButton("-", buttonStyle);
buttonMinus.setPosition(buttonHome.getX() - buttonWidth, buttonHome.getY());
stage.addActor(buttonMinus);
// Plus Button
buttonPlus = new TextButton("+", buttonStyle);
buttonPlus.setPosition(buttonHome.getX() + buttonWidth, buttonHome.getY());
stage.addActor(buttonPlus);
// TODO D-pad
// Left Trigger
float triggerWidth = Gdx.graphics.getWidth() * .1f;
float triggerHeight = Gdx.graphics.getHeight() * .1f;
if (config.triggersVisible)
buttonLeftTrigger = new TextButton("L", buttonStyle);
else
buttonLeftTrigger = new Button(new Button.ButtonStyle());
buttonLeftTrigger.setBounds(0, Gdx.graphics.getHeight() - triggerHeight, triggerWidth, triggerHeight);
stage.addActor(buttonLeftTrigger);
// Right Trigger
if (config.triggersVisible)
buttonRightTrigger = new TextButton("R", buttonStyle);
else
buttonRightTrigger = new Button(new Button.ButtonStyle());
buttonRightTrigger.setBounds(Gdx.graphics.getWidth() - triggerWidth,
Gdx.graphics.getHeight() - triggerHeight, triggerWidth, triggerHeight);
stage.addActor(buttonRightTrigger);
}
示例5: GameScreen
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public GameScreen(AsteroidsGame asteroidsGame){
//Load Assets
AsteroidAssetManager.getInstance();
stage = new Stage(new FitViewport(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()));
Player player = new Player(Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2, AsteroidsGame.TEAM_BLUE);
players.add(player);
stage.addActor(player);
stage.setKeyboardFocus(player);
for(int i =0; i < 4; i++){
float angle = (float) (Math.random() * 2 * Math.PI);
float x = (float) Math.cos(angle) * Gdx.graphics.getWidth();
float y = (float) Math.sin(angle) * Gdx.graphics.getHeight();
Asteroid ast = new Asteroid(x, y, 3, angle);
stage.addActor(ast);
}
Hud hud = new Hud(players);
stage.addActor(hud);
//Add TouchPad if the player is Android
if(Gdx.app.getType() == Application.ApplicationType.Android){
//Create a joystick skin
Skin touchpadSkin = new Skin();
touchpadSkin.add("touchBackground", new Texture("touchBackground.png"));
touchpadSkin.add("touchKnob", new Texture("touchKnob.png"));
touchpadSkin.add("touchKnob_pressed", new Texture("touchKnob_pressed.png"));
//Apply the Drawables to the TouchPad Style
Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
touchpadStyle.background = touchpadSkin.getDrawable("touchBackground");
touchpadStyle.knob = touchpadSkin.getDrawable("touchKnob");
//Create new TouchPad with the created style
this.joystick = new Touchpad(10, touchpadStyle);
this.joystick.setBounds(15, 15, 100, 100);
ImageButton.ImageButtonStyle buttonStyle = new ImageButton.ImageButtonStyle();
buttonStyle.imageUp = touchpadSkin.getDrawable("touchKnob");
buttonStyle.imageDown = touchpadSkin.getDrawable("touchKnob_pressed");
this.button = new ImageButton(buttonStyle);
this.button.setBounds(Gdx.graphics.getWidth()-115, 15, 100, 100);
stage.addActor(this.joystick);
stage.addActor(this.button);
}
}
示例6: createStyles
import com.badlogic.gdx.scenes.scene2d.ui.Touchpad; //导入方法依赖的package包/类
public void createStyles(ResourcesManager resourcesManager) {
if (!initialize) {
initialize=true;
font = resourcesManager.get(resourcesManager.DEFAULT_FONT);
font.setScale(ScaleUtil.getSizeRatio());
font.setUseIntegerPositions(false);
font2 = resourcesManager.get(resourcesManager.HEADER_FONT);
font2.setScale(ScaleUtil.getSizeRatio());
font2.setUseIntegerPositions(false);
skin = new Skin();
skin.add("default", font);
skin.add("header", font2);
skin.add("lt-blue", new Color(.62f, .76f, .99f, 1f));
skin.add("lt-green", new Color(.39f, .9f, .6f, 1f));
skin.add("dark-blue", new Color(.79f, .95f, 91f, 1f));
skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_ATLAS));
skin.addRegions(resourcesManager.<TextureAtlas>get(resourcesManager.GUI_PACK_ATLAS));
TextureRegionDrawable touchpad_background = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_background"));
TextureRegionDrawable touchpad_thumb = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.GUI_ATLAS)).findRegion("touchpad_thumb"));
TextureRegionDrawable checkox_true = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-on"));
TextureRegionDrawable checkox_false = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("check-off"));
TextureRegionDrawable slider_knob = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider-knob"));
TextureRegionDrawable slider = new TextureRegionDrawable(((TextureAtlas) resourcesManager.get(resourcesManager.UISKIN_ATLAS)).findRegion("default-slider"));
CheckBoxStyle checkBoxStyle = new CheckBox.CheckBoxStyle(checkox_false, checkox_true, font, Color.WHITE);
SpriteDrawable stats = new SpriteDrawable(new Sprite((Texture) resourcesManager.get(resourcesManager.STATS_BACKGROUND)));
SliderStyle sliderStyle = new SliderStyle(slider, slider_knob);
skin.add("default",new WindowStyle(font2,Color.ORANGE,skin.getDrawable("debug")));
skin.add("stats", stats);
LabelStyle lbs = new LabelStyle();
lbs.font = font;
lbs.fontColor = Color.WHITE;
skin.add("default", lbs);
LabelStyle lbsHeader = new LabelStyle();
lbsHeader.font = font2;
lbsHeader.fontColor = Color.WHITE;
skin.add("header", lbsHeader);
TextButtonStyle tbs = new TextButtonStyle(skin.getDrawable("btnMenu"), skin.getDrawable("btnMenuPress"), skin.getDrawable("btnMenu"), font);
tbs.fontColor = skin.getColor("dark-blue");
tbs.pressedOffsetX = Math.round(1f * Gdx.graphics.getDensity());
tbs.pressedOffsetY = tbs.pressedOffsetX * -1f;
ImageButton.ImageButtonStyle ImageButtonLeft = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonLeft"), skin.getDrawable("buttonLeftPress"),
skin.getDrawable("buttonLeft"), null, null, null);
ImageButton.ImageButtonStyle ImageButtonRight = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonRight"), skin.getDrawable("buttonRightPress"),
skin.getDrawable("buttonRight"), null, null, null);
ImageButton.ImageButtonStyle ImageButtonUp = new ImageButton.ImageButtonStyle(skin.getDrawable("buttonUp"), skin.getDrawable("buttonUpPress"),
skin.getDrawable("buttonUp"), null, null, null);
Touchpad.TouchpadStyle touchpadStyle = new Touchpad.TouchpadStyle();
touchpadStyle.background = touchpad_background;
touchpadStyle.knob = touchpad_thumb;
skin.add("default", tbs);
skin.add("buttonLeft", ImageButtonLeft);
skin.add("buttonRight", ImageButtonRight);
skin.add("buttonUp", ImageButtonUp);
skin.add("default", touchpadStyle);
skin.add("default", checkBoxStyle);
skin.add("default-horizontal", sliderStyle);
}
}