Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fi.tiko.tamk;
- import com.badlogic.gdx.Gdx;
- import com.badlogic.gdx.graphics.Texture;
- import com.badlogic.gdx.graphics.g2d.Batch;
- import com.badlogic.gdx.math.Interpolation;
- import com.badlogic.gdx.scenes.scene2d.Actor;
- import com.badlogic.gdx.scenes.scene2d.InputEvent;
- import com.badlogic.gdx.scenes.scene2d.InputListener;
- import com.badlogic.gdx.scenes.scene2d.Touchable;
- import com.badlogic.gdx.scenes.scene2d.actions.MoveToAction;
- public class RockActor extends Actor
- {
- private Texture rockPic;
- public Texture getRockPic()
- {
- return rockPic;
- }
- public RockActor()
- {
- rockPic = new Texture(Gdx.files.internal("Rock.png"));
- setTouchable(Touchable.enabled);
- setBounds(0, 0, rockPic.getWidth(), rockPic.getHeight());
- addListener(new RockListener());
- Gdx.app.log("ROCK", ": " + this);
- Gdx.app.log("ROCKw", ": " + this.getWidth());
- Gdx.app.log("ROCKx", ": " + this.getX());
- }
- @Override
- public void act(float delta)
- {
- super.act(delta);
- }
- @Override
- public void draw(Batch batch, float alpha)
- {
- batch.draw(rockPic,
- this.getX(), this.getY(),
- this.getOriginX(),
- this.getOriginY(),
- rockPic.getWidth(),
- rockPic.getHeight(),
- this.getScaleX(),
- this.getScaleY(),
- this.getRotation(), 0, 0,
- rockPic.getWidth(), rockPic.getHeight(), false, false);
- }
- class RockListener extends InputListener
- {
- @Override
- public void enter(InputEvent event, float x, float y, int pointer, Actor fromActor)
- {
- Gdx.app.log("Boom", ": " + event+" "+x+" "+y+" "+pointer+" "+fromActor);
- }
- @Override
- public boolean touchDown(InputEvent event, float x, float y, int pointer, int button)
- {
- Gdx.app.log("X", ": " + x);
- Gdx.app.log("Y", ": " + y);
- MoveToAction moveToAction = new MoveToAction();
- moveToAction.setPosition(420, 300);
- moveToAction.setDuration(1f);
- moveToAction.setInterpolation(Interpolation.bounceOut);
- addAction(moveToAction);
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement