List of usage examples for com.badlogic.gdx.scenes.scene2d.actors Image Image
public Image(String name, TextureRegion region)
From source file:com.badlogic.gdx.tests.lw.StageTestLW.java
License:Apache License
@Override public void create() { texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); font = new BitmapFont(); stage = new Stage(480, 320, false); float loc = (NUM_SPRITES * (32 + SPACING) - SPACING) / 2; for (int i = 0; i < NUM_GROUPS; i++) { Group group = new Group("group" + i); group.x = (float) Math.random() * (stage.width() - NUM_SPRITES * (32 + SPACING)); group.y = (float) Math.random() * (stage.height() - NUM_SPRITES * (32 + SPACING)); group.originX = loc;//from w w w . j a va 2s . co m group.originY = loc; fillGroup(group, texture); stage.addActor(group); } uiTexture = new Texture(Gdx.files.internal("data/ui.png")); uiTexture.setFilter(TextureFilter.Linear, TextureFilter.Linear); ui = new Stage(480, 320, false); Image blend = new Image("blend button", new TextureRegion(uiTexture, 0, 0, 64, 32)); blend.y = ui.height() - 64; Image rotate = new Image("rotate button", new TextureRegion(uiTexture, 64, 0, 64, 32)); rotate.y = blend.y; rotate.x = 64; Image scale = new Image("scale button", new TextureRegion(uiTexture, 64, 32, 64, 32)); scale.y = blend.y; scale.x = 128; ui.addActor(blend); ui.addActor(rotate); ui.addActor(scale); Label fps = new Label("fps", font, "fps: 0"); fps.x = 10; fps.y = 30; fps.color.set(0, 1, 0, 1); ui.addActor(fps); Thread.currentThread().setPriority(Thread.MAX_PRIORITY); renderer = new ImmediateModeRenderer(); Gdx.input.setInputProcessor(this); }
From source file:com.badlogic.gdx.tests.lw.StageTestLW.java
License:Apache License
private void fillGroup(Group group, Texture texture) { float advance = 32 + SPACING; for (int y = 0; y < NUM_SPRITES * advance; y += advance) for (int x = 0; x < NUM_SPRITES * advance; x += advance) { Image img = new Image(group.name + "-sprite" + x * y, texture); img.x = x;/*from ww w. ja va 2 s.c om*/ img.y = y; img.width = 32; img.height = 32; group.addActor(img); images.add(img); } }
From source file:com.game.HelloWorld.java
License:Apache License
@Override public void create() { // Stage pour scene2D mT = new Texture(Gdx.files.internal("data/ball.png")); texture = new Texture(Gdx.files.internal("data/main_char.png")); mMainCharBatch = new SpriteBatch(); mMainCharRegions[0] = new TextureRegion(texture, 0, 0, 0.25f, 0.25f); mMainCharRegions[1] = new TextureRegion(texture, 0.25f, 0, 0.5f, 0.25f); mMainCharRegions[2] = new TextureRegion(texture, 0.5f, 0, 0.75f, 0.25f); mMainCharRegions[3] = new TextureRegion(texture, 0, 0.25f, 0.25f, 0.5f); mMainCharRegions[4] = new TextureRegion(texture, 0.25f, 0.25f, 0.5f, 0.5f); mMainCharRegions[5] = new TextureRegion(texture, 0.5f, 0.25f, 0.75f, 0.5f); mMainCharRegions[6] = new TextureRegion(texture, 0, 0.5f, 0.25f, 0.75f); mMainCharRegions[7] = new TextureRegion(texture, 0.25f, 0.5f, 0.5f, 0.75f); mMainCharRegions[8] = new TextureRegion(texture, 0.5f, 0.5f, 0.75f, 0.75f); mMainCharRegions[9] = new TextureRegion(texture, 0, 0.75f, 0.25f, 1.0f); mMainCharRegions[10] = new TextureRegion(texture, 0.25f, 0.75f, 0.5f, 1.0f); mMainCharRegions[11] = new TextureRegion(texture, 0.5f, 0.75f, 0.75f, 1.0f); Image mainChar = new Image("mainChar", mT); mainChar.x = Gdx.graphics.getWidth() / 2; mainChar.y = Gdx.graphics.getHeight() / 2; mRenderTree = new RenderTree(); mRenderTree.getStage().addActor(mainChar); mRenderTree.getStage().addActor(BallSplash.getInstance()); Gdx.input.setInputProcessor(this); font = new BitmapFont(); font.setColor(Color.RED);/* w w w. j a v a 2 s. c o m*/ // Define the audio source music = Gdx.audio.newMusic(Gdx.files.internal("data/music.mp3")); sound = Gdx.audio.newSound(Gdx.files.internal("data/sound.ogg")); music.setLooping(true); music.setVolume(0.0f); music.play(); // Define the orthographic cam mCamera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); this.create_tiledMap(); this.mCamera.position.set(new Vector3(this.mTileMapRenderer.getMapWidthUnits() / 2, this.mTileMapRenderer.getMapHeightUnits() / 2, 0)); this.mCamera.update(); }