Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.mygdx.bug;
- import com.badlogic.gdx.ApplicationAdapter;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.Input;
- import com.badlogic.gdx.graphics.GL20;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.SpriteBatch;
- import com.badlogic.gdx.scenes.scene2d.Stage;
- import com.badlogic.gdx.scenes.scene2d.ui.Image;
- import com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup;
- import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
- import com.badlogic.gdx.utils.Align;
- public class MyGdxBug extends ApplicationAdapter {
- SpriteBatch batch;
- Texture img;
- float red = 1;
- float green = 0;
- float blue = 0;
- Image imgg;
- Stage stage;
- WidgetGroup group;
- TextureRegionDrawable bgImg;
- @Override
- public void create () {
- batch = new SpriteBatch();
- img = new Texture("badlogic.jpg");
- stage = new Stage();
- bgImg = new TextureRegionDrawable(img);
- imgg = new Image(bgImg);
- group = new WidgetGroup(imgg);
- stage.addActor(group);
- group.setFillParent(true);
- imgg.setPosition(150,150);
- stage.setDebugAll(true);
- }
- @Override
- public void render () {
- Gdx.gl.glClearColor(red, green, blue, 1);
- Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
- stage.act();
- stage.draw();
- batch.begin();
- bgImg.draw(batch,
- imgg.getX(Align.left), imgg.getY(Align.bottom),
- imgg.getX(Align.center), imgg.getY(Align.center),
- imgg.getWidth(), imgg.getHeight(),
- imgg.getScaleX(), imgg.getScaleY(),
- imgg.getRotation());
- batch.end();
- if(Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
- imgg.rotateBy(Gdx.graphics.getDeltaTime() * 100);
- System.out.println(imgg.getRotation());
- }
- }
- @Override
- public void dispose () {
- batch.dispose();
- img.dispose();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement