您好,登錄后才能下訂單哦!
package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
public class MyGdxGame implements ApplicationListener{
Stage stage;
@Override
public void create() {
stage= new Stage(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), false);
TextureAtlas atlas= new TextureAtlas(Gdx.files.internal("data/pack")); // 根據pack文件獲取所有圖片
Image p_w_picpath2= new Image(atlas.findRegion("14")); // 獲取名為14的圖片,并創建一個Image對象
p_w_picpath2.scale(0.02f, 0.02f);
p_w_picpath2.setPosition(200, 50);
Image p_w_picpath3= new Image(atlas.findRegion("6"));
p_w_picpath2.setPosition(40, 40);
p_w_picpath2.scale(0.5f, 0.5f);
stage.addActor(p_w_picpath2);
stage.addActor(p_w_picpath3);
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void pause() {
// TODO Auto-generated method stub
}
@Override
public void render() {
Gdx.gl.glClear(GL10.GL_COLOR_BUFFER_BIT);
stage.act(Gdx.graphics.getDeltaTime());
stage.draw();
}
@Override
public void resize( int width, int height) {
// TODO Auto-generated method stub
}
@Override
public void resume() {
// TODO Auto-generated method stub
}
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。