本文整理汇总了Java中com.badlogic.gdx.Gdx类的典型用法代码示例。如果您正苦于以下问题:Java Gdx类的具体用法?Java Gdx怎么用?Java Gdx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Gdx类属于com.badlogic.gdx包,在下文中一共展示了Gdx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Addtogroup
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void Addtogroup(){
grchatfaction = new VerticalGroup();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
try {
grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Welcome Chat!"));
grchatfaction.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.BLUE,"Faction!"));
grchatfaction.addActor(labelTest1);
} catch (ParseException e) {
e.printStackTrace();
Gdx.app.log("eroare","intra");
}
sp = new ScrollPane(grchatfaction);
sp.layout();
sp.setScrollingDisabled(true, false);
sp.setFillParent(true);sp.setLayoutEnabled(true);
ta = new Table();
ta.setFillParent(false);
ta.add(sp).fill().expand();
ta.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
ta.setVisible(false);
groupbotttom.addActor(ta);
sp.setScrollPercentY(200);
sp.act(Gdx.graphics.getDeltaTime());
sp.updateVisualScroll();
}
示例2: draw
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void draw(Batch batch) {
vanishElapsed += Gdx.graphics.getDeltaTime();
// vanishElapsed might be < 0 (delay), so clamp to 0
float progress = Math.min(1f,
Math.max(vanishElapsed, 0f) / vanishLifetime);
// If one were to plot the elasticIn function, they would see that the slope increases
// a lot towards the end- a linear interpolation between the last size + the desired
// size at 20% seems to look a lot better.
vanishSize = MathUtils.lerp(
vanishSize,
Interpolation.elasticIn.apply(cell.size, 0, progress),
0.2f
);
float centerOffset = cell.size * 0.5f - vanishSize * 0.5f;
Cell.draw(vanishColor, batch, cell.pos.x + centerOffset, cell.pos.y + centerOffset, vanishSize);
}
示例3: StageLoad
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
/**
* Loading stage
* @param doLoad should resources be loaded? It acts as a splash screen otherwise.
*/
public StageLoad(boolean doLoad) {
this.doLoad = doLoad;
// Create icon
icon = new Image(new Texture("image/icon-512.png"));
int size = Gdx.graphics.getHeight();
if (Gdx.graphics.getHeight() > Gdx.graphics.getWidth())
size = Gdx.graphics.getWidth();
icon.setSize(size, size);
icon.setPosition(Gdx.graphics.getWidth() / 2 - size / 2,
Gdx.graphics.getHeight() / 2 - icon.getHeight() / 2);
addActor(icon);
// Loading Text
Label.LabelStyle loadingStyle = new Label.LabelStyle();
loadingStyle.font = new BitmapFont(Gdx.files.internal("font/collvetica.fnt"));
loadingStyle.font.getData().setScale(Gdx.graphics.getHeight() * 2 / 720);
loading = new Label("DRC Sim", loadingStyle);
loading.setBounds(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight() * .2f);
loading.setAlignment(Align.center);
addActor(loading);
}
示例4: addchatlocation
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void addchatlocation(){
grchatlocation = new VerticalGroup();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd/HH:mm:ss");
try {
grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.RED,"Welcome Chat!"));
grchatlocation.addActor(addComment(sdf.parse("2016/5/17/13:34:23"),"adrian", Color.GREEN,"Location!"));
grchatlocation.addActor(labelTest);
} catch (ParseException e) {
e.printStackTrace();
Gdx.app.log("eroare","intra");
}
scrollchatpublic = new ScrollPane(grchatlocation);
scrollchatpublic.layout();
scrollchatpublic.setScrollingDisabled(true, false);
scrollchatpublic.setFillParent(true);
scrollchatpublic.setLayoutEnabled(true);
tablechatpublic = new Table();
tablechatpublic.setFillParent(false);
tablechatpublic.add(scrollchatpublic).fill().expand();
tablechatpublic.setBounds(WIDTH *0.05f,background1.getY(), WIDTH*0.9f,background1.getHeight() * 1.05f);
groupbotttom.addActor(tablechatpublic);
scrollchatpublic.setScrollPercentY(100);
scrollchatpublic.act(Gdx.graphics.getDeltaTime());
scrollchatpublic.updateVisualScroll();
}
示例5: render
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void render(float delta) {
Gdx.gl.glClearColor(backgroundColor.r, backgroundColor.g,
backgroundColor.b, backgroundColor.a);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
game.getSpriteBatch().begin();
if (backgroundTexture != null)
game.getSpriteBatch().draw(this.backgroundTexture, 0, 0,
game.getViewportWidth(), game.getViewportHeight());
game.getSpriteBatch().setProjectionMatrix(game.getUICamera().combined);
stage.act(delta);
stage.draw();
game.getSpriteBatch().end();
}
示例6: takeScreenshot
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public static void takeScreenshot() {
byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0,
Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight(), true);
Pixmap pixmap = new Pixmap(Gdx.graphics.getBackBufferWidth(),
Gdx.graphics.getBackBufferHeight(), Pixmap.Format.RGBA8888);
BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length);
SimpleDateFormat dateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH-mm-ss");
PixmapIO.writePNG(
Gdx.files.external(dateFormat.format(new Date()) + ".png"),
pixmap);
pixmap.dispose();
}
示例7: draw
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void draw() {
if (shown) {
// Draw an overlay rectangle with not all the opacity
// This is the only place where ShapeRenderer is OK because the batch hasn't started
Gdx.gl.glEnable(GL20.GL_BLEND);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
Color color = new Color(Klooni.theme.bandColor);
color.a = 0.1f;
shapeRenderer.setColor(color);
shapeRenderer.rect(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
shapeRenderer.end();
}
super.draw();
}
示例8: loadSpawns
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public static List<Spawn> loadSpawns(BufferedReader data) {
if (data == null)
return null;
List<Spawn> spawns = new ArrayList<com.logicmaster63.tdgalaxy.map.Spawn>();
try {
int spawnNum = Integer.parseInt(data.readLine());
for (int i = 0; i < spawnNum; i++) {
int repeatNum = Integer.parseInt(data.readLine());
String name = data.readLine();
int delay = Integer.parseInt(data.readLine());
for (int j = 0; j < repeatNum; j++)
spawns.add(new Spawn(name, delay));
data.close();
}
} catch (IOException e) {
Gdx.app.error("Error", e.toString());
}
return spawns;
}
示例9: getSave
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
private static Save getSave(CubesCmdLineOptions.ServerCmdLineOptions options) {
FileHandle worldFolder = Compatibility.get().getBaseFolder().child("world");
if (options.worldFolder != null)
worldFolder = Gdx.files.absolute(options.worldFolder);
Save save = new Save("world", worldFolder);
if (save.readSaveOptions() == null) {
SaveOptions saveOptions = save.getSaveOptions();
if (options.worldSeedString != null)
saveOptions.setWorldSeed(options.worldSeedString);
if (options.worldGenerator != null)
saveOptions.worldType = options.worldGenerator;
if (options.worldGamemode != null)
saveOptions.worldGamemode = options.worldGamemode;
}
return save;
}
示例10: GameOver
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public GameOver(GameStateManager gsm, int score) {
super(gsm);
this.score = score;
camera.setToOrtho(false, FlappyBaran.WIDTH / 2, FlappyBaran.HEIGHT / 2);
background = new Texture("backgrnd.jpg");
gameover = new Texture("gameover.png");
font = new BitmapFont();
prefs = Gdx.app.getPreferences("FlappyBaran");
if (!prefs.contains("highScore")) {
prefs.putInteger("highScore", 0);
}
prevHighScore = getHighScore();
if (prevHighScore < this.score) {
setHighScore(this.score);
highscore = this.score;
} else {
highscore = prevHighScore;
}
}
示例11: initImageButtons
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
private void initImageButtons() {
if (!sceneData.isGameHost()) {
return; // player is not hosting - don't offer the player to start the game.
}
imageButtonStartGame = new ImageButtonSceneObject(sceneData.createImageButton(Assets.START_GAME_BUTTON_FILENAME), buttonPressedSound);
imageButtonStartGame.setBounds((Gdx.graphics.getWidth() / 2.0f) - 137.5f, Gdx.graphics.getHeight() / 10.0f, 275f, 240f);
imageButtonStartGame.addListener(new ClickListener() {
@Override
public void clicked(InputEvent event, float x, float y) {
sceneData.sendMessageFromGui(new StartGameClicked());
}
});
addSceneObject(imageButtonStartGame);
imageButtonStartGame.setDisabled();
}
示例12: handleOutboundMessage
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void handleOutboundMessage(Message message) {
if (message instanceof DisconnectClient) {
handleDisconnect(((DisconnectClient)message).isTerminateClient());
return;
}
try {
byte[] data = new MessageSerializer(message).serialize();
write(data);
} catch (IOException | ProtocolException e) {
Gdx.app.error(getClass().getSimpleName(), "Handling outbound message failed", e);
handleDisconnect(true);
}
}
示例13: downenergy
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
public void downenergy(int value){
bar.act(Gdx.graphics.getDeltaTime());
infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy() - value);
FadeIn();
new Timer().schedule(new Timer.Task() {
@Override
public void run() {
bar.setAnimateDuration(3);
bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
mapsScreen.startTimer();
}
}, 1000);
}
示例14: handleMessage
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void handleMessage(String senderId, Message message) {
if(message.getType().equals(NextPlayer.class)){
setNextPlayer(((NextPlayer)message).getPlayername());
} else if (message.getType().equals(IsAttacked.class)) {
context.setState(new AttackState(context, false));
} else if (message.getType().equals(AttackResult.class)) { // react on broadcast attack result as we have to update the regions
updateRegions((AttackResult)message);
} else if (message.getType().equals(SpawnTroop.class)) {
doSpawnTroop((SpawnTroop) message);
} else if (message.getType().equals(MoveTroop.class)) {
doMoveTroop((MoveTroop) message);
}
else{
Gdx.app.log("WaitingForNextTurnState","unknown messgae:"+message.getType().getSimpleName());
}
}
示例15: show
import com.badlogic.gdx.Gdx; //导入依赖的package包/类
@Override
public void show() {
if(drawone){
addroomselect();
addButtonBottom();
addPuls();
addimagebg();
addbuildRoom();
addtimerbuildroom();
drawone = false;
}
cameraGroupStrategy = new CameraGroupStrategy(camera);
// CameraInputController controller = new CameraInputController(camera);
stage = new Stage(new StretchViewport(Gdx.graphics.getWidth(),Gdx.graphics.getHeight()));
batchsprite = new SpriteBatch();
addtostage();
batch = new DecalBatch(this.cameraGroupStrategy);
Gdx.input.setCatchBackKey(true);
InputMultiplexer inputmulti = new InputMultiplexer();
inputmulti.addProcessor(stage);
Gdx.input.setInputProcessor(inputmulti);
}