本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Sprite.setOrigin方法的典型用法代碼示例。如果您正苦於以下問題:Java Sprite.setOrigin方法的具體用法?Java Sprite.setOrigin怎麽用?Java Sprite.setOrigin使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.Sprite
的用法示例。
在下文中一共展示了Sprite.setOrigin方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: GameActor
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height) {
actor_texture = actor_region;
xpos = x_pos ;
ypos = y_pos ;
width_ =width ;
height_ = height;
actor_Sprite = new Sprite(actor_texture);
actor_Sprite.setX(xpos);
actor_Sprite.setY(ypos);
if(color != null){
actor_Sprite.setColor(color);}
actor_Sprite.setSize(width_, height_);
actor_Sprite.setOrigin(width_/2, height_/2);
setBounds(xpos, ypos, width_, height_);
this.setTouchable(Touchable.enabled);
}
示例2: draw
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
if (sprite != null && !sprite.isEmpty() && !sprite.equals(NO_SPRITE)) {
Sprite render = layer.getGameSprite(sprite);
render.setPosition(MathUtils.round(getX()), MathUtils.round(getY()));
render.setRotation(getRotation());
render.setAlpha(getColor().a * parentAlpha);
render.setOrigin(getOriginX(), getOriginY());
render.setColor(getColor());
render.setSize(getWidth(), getHeight());
render.setScale(getScaleX(), getScaleY());
render.setFlip(flip_x, flip_y);
render.draw(batch);
}
super.draw(batch, parentAlpha);
}
示例3: create
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void create() {
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
camera = new OrthographicCamera(1, h/w);
batch = new SpriteBatch();
texture = new Texture(Gdx.files.internal("data/libgdx.png"));
texture.setFilter(TextureFilter.Linear, TextureFilter.Linear);
TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200);
sprite = new Sprite(region);
sprite.setSize(1f, sprite.getHeight() / sprite.getWidth());
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
sprite.setPosition(-.5f, -.5f);
}
示例4: initializeSprite
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void initializeSprite() {
SCALE = 2.5f;
SPEED = 25f;
CURRENT_STATE = STATE.STATIONARY;
SPRITE = new Sprite(AssetDoctor.getSprite("fry_02"));
resizeSprite(SPRITE);
SPRITE.setOrigin(SPRITE.getWidth()/2.0f, 0f);
SPRITE.rotate(ROTATION);
}
示例5: initBars
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void initBars() {
bars = new ArrayList<Sprite>();
for(int i = 0; i < NUM_BARS; i++) {
Sprite bar = new Sprite(AssetDoctor.getSprite("color_white"));
bar.setOrigin(0f, 0f);
bar.setColor(Color.BLACK);
height = DS.T_HEIGHT/(float)NUM_BARS;
bar.setSize(DS.T_WIDTH, height);
bar.setPosition(0, i*height);
bars.add(bar);
}
}
示例6: resizeSprite
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
protected void resizeSprite(Sprite sprite) {
sprite.setOrigin(0f, 0f);
sprite.setSize(sprite.getWidth()*SCALE, sprite.getHeight()*SCALE);
sprite.setOrigin(sprite.getWidth()/2.0f, sprite.getHeight()/2.0f);
sprite.setPosition(x - sprite.getWidth()/2.0f, y - sprite.getHeight()/2.0f);
}
示例7: resizeSprite
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void resizeSprite(Sprite sprite) {
sprite.setOrigin(0f, 0f);
sprite.setSize(sprite.getWidth()*SCALE, sprite.getHeight()*SCALE);
sprite.setOrigin(sprite.getWidth()/2.0f, sprite.getHeight()/2.0f);
sprite.setPosition(x, y);
}
示例8: loadSprite
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public static Sprite loadSprite(String id, String file, float scaleX, float scaleY) {
Sprite sprite = loadSprite(id, file);
sprite.setScale(scaleX, scaleY);
sprite.setOrigin(0, 0);
return sprite;
}