本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Sprite.setPosition方法的典型用法代碼示例。如果您正苦於以下問題:Java Sprite.setPosition方法的具體用法?Java Sprite.setPosition怎麽用?Java Sprite.setPosition使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.graphics.g2d.Sprite
的用法示例。
在下文中一共展示了Sprite.setPosition方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: processEntity
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
protected void processEntity(Entity entity, float deltaTime) {
if (_tile != null) {
_batch.begin();
TextureRegion textureRegion = _tile.getCell().getTile().getTextureRegion();
Sprite sprite = new Sprite(textureRegion);
if (!isLegalPlacement()) {
sprite.setColor(Color.RED);
sprite.setAlpha(0.5f);
} else {
sprite.setColor(Color.GREEN);
sprite.setAlpha(0.5f);
}
sprite.setPosition(_tile.getCords().x, _tile.getCords().y);
sprite.draw(_batch);
_batch.end();
}
}
示例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 () {
batch = new SpriteBatch();
img = new Texture("coche.png");
miCoche= new Sprite(img);
miCoche.setPosition(0,20);
miCoche.setSize(200,100);
}
示例4: Ion
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public Ion(float posX, float posY, boolean flip)
{
speed = 400;
lifeTime = 180;
flashLTime = 25;
damage = 2;
alive = true;
this.posX = posX;
this.posY = posY;
bulletTexture = AssetLoader.assetManager.get("ion.png", Texture.class);
bulletFlash = AssetLoader.assetManager.get("ionflash.png", Texture.class);
bulletSound = AssetLoader.assetManager.get("ionsnd.wav", Sound.class);
if(!flip)
bulletSound.play();
sprite = new Sprite(bulletTexture);
sprite.setOriginCenter();
sprite.setPosition(this.posX,this.posY);
this.flip = flip;
if(flip)
sprite.setRotation(180);
}
示例5: create
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public void create()
{
posX = Gdx.graphics.getWidth()/2;
posY = Gdx.graphics.getHeight()/2-300;
speed = 400;
//Hardcoded staff. I could use textureAtlas but I'm lazy.
textures = new Texture[3];
textureRegionGuns = new TextureRegion[2];
textures[0] = AssetLoader.assetManager.get("spaceshipHull.png", Texture.class);
textures[1] = AssetLoader.assetManager.get("spaceshipGun.png", Texture.class);
textures[2] = AssetLoader.assetManager.get("spaceshipJet.png", Texture.class);
textureRegionGuns[0] = new TextureRegion(textures[1]);
textureRegionGuns[1] = new TextureRegion(textures[1]);
textureRegionGuns[0].flip(true, false);
sprite = new Sprite(textures[0]);
sprite.setOriginCenter();
sprite.setPosition(posX, posY);
bulletType = BulletType.ROCKET;
delay = delayWithAttack;
}
示例6: 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);
}
示例7: drawNametable
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;
boolean toggleNametableEarly = false;
if (scrollY > 239 && scrollY <= 255) {
scrollY -= 16;
toggleNametableEarly = true;
}
int coarseScrollX = scrollX >> 3;
int coarseScrollY = scrollY >> 3;
int fineScrollX = scrollX & 7;
int fineScrollY = scrollY & 7;
int nameTableX = coarseScrollX;
int nameTableY = coarseScrollY;
int actualNameTableX;
int actualNameTableY;
int screenX = 0;
int screenY = 8;
int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
int nameTableColumnCount = 33;
int nameTable;
while (nameTableColumnCount > 0) {
screenY = 0;
nameTableRowCount = fineScrollY == 0 ? 30 : 31;
nameTableY = coarseScrollY;
nameTable = (ggvm.getNametableAddress() == Ppu.NAME_TABLE_0_BASE_ADDRESS) ? 0 : 1;
if (toggleNametableEarly) {
nameTable ^= 1;
}
while (nameTableRowCount > 0) {
actualNameTableX = nameTableX % 32;
actualNameTableY = nameTableY % 30;
int whichNameTable = nameTable ^ (nameTableY / 30);
int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_2_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_2_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;
int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);
int indexRow = index >> 4;
int indexColumn = index & 0x0f;
Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
sprite.setColor(0, attributes[attribute], 0, 0);
if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
sprite.draw(spriteBatch);
}
screenY += 8;
nameTableY++;
nameTableRowCount--;
}
screenX += 8;
nameTableX++;
nameTableColumnCount--;
}
}
示例8: draw
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
@Override
public void draw(Batch batch, float parentAlpha) {
// TODO Auto-generated method stub
super.draw(batch, parentAlpha);
if(is_me_get_focus == false){
if(Math.pow(this.page_no-book.current_page,2)<=book.pages_range_to_load){
page_textrue=new Texture(Gdx.files.internal("pagestray/p"+page_no+".png"));
page_textrue.setFilter(TextureFilter.Linear,TextureFilter.Linear);
page_sprite = new Sprite(page_textrue);
page_sprite.setSize(Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
is_me_get_focus = true;
//book.android.make_toast("page no : "+page_no+" loaded", false);
}
}else
{
b_a_s.setColor(255/255f,27/255f,177/255f,book.bookmark_a_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
b_b_s.setColor(27/255f,255/255f,215/255f,book.bookmark_b_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
b_c_s.setColor(255/255f,220/255f,27/255f,book.bookmark_c_page == page_no? (book.stage_detector==Stages.menu?.6f:(book.them_detector ==Thems.colord?.5f:.4f)):0);
b_a_s.setPosition(b_first_x,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+ b_y);
b_b_s.setPosition(b_first_x+b_pading_x+b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
b_c_s.setPosition(b_first_x+2*b_pading_x+2*b_width, book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight()+b_y);
back_ground.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
britness.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
page_sprite.setPosition(0,book.pages_scroll_pane.getScrollY()-(page_no-1)*Gdx.graphics.getHeight());
page_sprite.setAlpha(book.stage_detector==Stages.menu?.3f:1);
back_ground.setAlpha(book.them_detector ==Thems.colord?1:0);
britness.setAlpha(1f-(book.light_value*.01f));
back_ground.draw(batch);
page_sprite.draw(batch);
britness.draw(batch);
b_a_s.draw(batch);
b_b_s.draw(batch);
b_c_s.draw(batch);
}
if(Math.pow(this.page_no-book.current_page,2)>book.pages_range_to_load&&is_me_get_focus){
// book.android.make_toast("page no : "+page_no+" unloaded", false);
is_me_get_focus = false ;
page_sprite = null ;
page_textrue.dispose() ;
}
}
示例9: drawNametable
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int startingNametableAddress, int scrollX, int scrollY, float splitYStart, float splitYEnd) {
int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1;
int coarseScrollX = scrollX >> 3;
int coarseScrollY = scrollY >> 3;
int fineScrollX = scrollX & 7;
int fineScrollY = scrollY & 7;
int nameTableX = coarseScrollX;
int nameTableY = coarseScrollY;
int actualNameTableX;
int actualNameTableY;
int screenX = 0;
int screenY = 0;
int nameTableRowCount = fineScrollY == 0 ? 30 : 31;
int nameTableColumnCount;
int nameTable;
while (nameTableRowCount > 0) {
screenX = 0;
nameTableColumnCount = fineScrollX == 0 ? 32 : 33;
nameTableX = coarseScrollX;
nameTable = (startingNametableAddress == Ppu.NAME_TABLE_0_BASE_ADDRESS || startingNametableAddress == Ppu.NAME_TABLE_2_BASE_ADDRESS) ? 0 : 1;
while (nameTableColumnCount > 0) {
actualNameTableX = nameTableX % 32;
actualNameTableY = nameTableY % 30;
int whichNameTable = nameTable ^ ((nameTableX >> 5) & 1);
int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS;
int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS;
int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY);
int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY);
int indexRow = index >> 4;
int indexColumn = index & 0x0f;
Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn];
sprite.setColor(0, attributes[attribute], 0, 0);
if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) {
sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY);
sprite.draw(spriteBatch);
}
screenX += 8;
nameTableX++;
nameTableColumnCount--;
}
screenY += 8;
nameTableY++;
nameTableRowCount--;
}
}
示例10: loadPlanet
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
private void loadPlanet(Json json, JsonValue jsonData) {
planet = json.readValue("planet", Planet.class, jsonData);
Pixmap loadPixmap = new Pixmap(1024, 1024, Pixmap.Format.RGBA8888);
int index = 0;
for(int x = 0; x < 1024; x++) {
for (int y = 0; y < 1024; y++) {
int color = 0;
switch (planet.getTextureString().charAt(index)) {
case 'd':
color = Color.rgba8888(47f / 255f, 86f / 255f, 118f / 255f, 1f);
break;
case 'o':
color = Color.rgba8888(62f / 255f, 120f / 255f, 160f / 255f, 1f);
break;
case 'l':
color = Color.rgba8888(146f / 255f, 209f / 255f, 135f / 255f, 1f);
break;
}
index++;
loadPixmap.setColor(color);
loadPixmap.drawPixel(x, y);
}
}
Sprite sprite = new Sprite(new Texture(loadPixmap));
sprite.setSize(planet.getSize(), planet.getSize());
sprite.setPosition(CENTER_X - planet.getSize() / 2, CENTER_Y - planet.getSize() / 2);
planet = new Planet(sprite, loadPixmap, objectGenerator.getVelDir());
spaceObjects.add(planet);
}
示例11: HealthPack
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public HealthPack()
{
posX = MathUtils.random(350)+ 50;
posY = Gdx.graphics.getHeight();
speed = 150f;
texture = AssetLoader.assetManager.get("medkit.png", Texture.class);
powerUpSound = AssetLoader.assetManager.get("powerupsnd.wav", Sound.class);
sprite = new Sprite(texture);
sprite.setOriginCenter();
sprite.setScale(0.7f);
sprite.setPosition(posX, posY);
}
示例12: AmmoPack
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public AmmoPack()
{
posX = MathUtils.random(350)+ 50;
posY = Gdx.graphics.getHeight();
speed = 150f;
texture = AssetLoader.assetManager.get("ammo.png", Texture.class);
powerUpSound = AssetLoader.assetManager.get("powerupsnd.wav", Sound.class);
sprite = new Sprite(texture);
sprite.setOriginCenter();
sprite.setScale(0.7f);
sprite.setPosition(posX, posY);
}
示例13: create
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
/**
* Initialisierung
*
* @param game zeigt auf das SchoolGame, dass das Spiel verwaltet
*/
@Override
public void create(SchoolGame game) {
this.game = game;
batch = new SpriteBatch();
Texture splashImg = new Texture(Gdx.files.internal("data/misc/splashscreen.png"));
screenSprite = new Sprite(splashImg);
screenSprite.setPosition(-screenSprite.getWidth() / 2, -screenSprite.getHeight() / 2);
screenSprite.setAlpha(0);
timer = SHOW_TIME + FADE_TIME * 2;
}
示例14: GodPack
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public GodPack()
{
posX = MathUtils.random(350)+ 50;
posY = Gdx.graphics.getHeight();
speed = 150f;
texture = AssetLoader.assetManager.get("god.png", Texture.class);
powerUpSound = AssetLoader.assetManager.get("powerupsnd.wav", Sound.class);
sprite = new Sprite(texture);
sprite.setOriginCenter();
sprite.setScale(0.7f);
sprite.setPosition(posX, posY);
}
示例15: init
import com.badlogic.gdx.graphics.g2d.Sprite; //導入方法依賴的package包/類
public static void init(SpriteBatch batch){
textureAtlas = new TextureAtlas("spriteSheet.pack");
floorMiddle = new Sprite(textureAtlas.findRegion("middle"));
floorMiddle.setPosition(0,0);
}