SpriteBatch batcher = new SpriteBatch();
batcher.draw(TextureRegion region,
float x,
float y,
float originX,
float originY,
float width,
float height,
float scaleX,
float scaleY,
float rotation)
Run Code Online (Sandbox Code Playgroud)
是什么意思originX,originY,scaleX,scaleY,rotation?你也可以给我一个他们使用的例子吗?
你为什么不看文件?
正如文档中所述,原点是左下角originX,originY是偏离此原点的.例如,如果您希望对象围绕其中心旋转,您将执行此操作.
originX = width/2;
originY = height/2;
Run Code Online (Sandbox Code Playgroud)
通过指定scaleX,scaleY缩放图像,如果要使Sprite 2x更大,则将scaleX和scaleY都设置为数字2.
rotation 指定以度为单位的原点旋转.
此代码片段绘制围绕其中心旋转90度的纹理
SpriteBatch batch = new SpriteBatch();
Texture texture = new Texture(Gdx.files.internal("data/libgdx.png"));
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
int textureWidth = texture.getWidth();
int textureHeight = texture.getHeight();
float rotationAngle = 90f;
TextureRegion region = new TextureRegion(texture, 0, 0, textureWidth, textureHeight);
batch.begin();
batch.draw(region, 0, 0, textureWidth / 2f, textureHeight / 2f, textureWidth, textureHeight, 1, 1, rotationAngle, false);
batch.end();
Run Code Online (Sandbox Code Playgroud)
或者在这里看一下教程.
| 归档时间: |
|
| 查看次数: |
11373 次 |
| 最近记录: |