Image控件作为一名actor存在.任然需要texture将文件转化为纹理对象,
texturegion对象,对图像进行进一步的处理(当然也可以直接在Image构造中传入texture对象)
以下是image中的方法
image.setColor(Color.PINK);//设置图片颜色
image.setScale(0.5f);//设置缩放比
image.setRotation(0);//设置旋转角度
image.setPosition(100, 50);//设置起始位置
image.setOrigin(0, 0);//设置旋转中心
package com.me.mygdxgame;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
public class MyGdxGame implements ApplicationListener {
private Texture tex;
private TextureRegion tr;
private Image image;
private Stage stage;
@Override
public void create() {
tex = new Texture(Gdx.files.internal