本文整理匯總了Java中com.badlogic.gdx.graphics.g2d.Sprite類的典型用法代碼示例。如果您正苦於以下問題:Java Sprite類的具體用法?Java Sprite怎麽用?Java Sprite使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Sprite類屬於com.badlogic.gdx.graphics.g2d包,在下文中一共展示了Sprite類的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: 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);
}
示例3: initialize
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
@Override
public void initialize() {
//Allocate a pixmap big enough to accommodate four banks of pattern
//tables (bg and spr each for all four banks)
patternTablePixmap = new Pixmap(128, 1024, Pixmap.Format.RGBA8888);
//Set blending to none so we can rewrite the pixmap and draw it to the
//pattern table texture when graphics are regenerated.
patternTablePixmap.setBlending(Pixmap.Blending.None);
//Allocate a pixmap the size of one tile for live CHR-RAM updates.
patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888);
patternPixmap.setBlending(Pixmap.Blending.None);
patternTableTexture = new Texture(patternTablePixmap, false);
TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8);
patternTableSprites = new Sprite[128][16];
for(int row = 0; row < 128; row++) {
for(int column = 0; column < 16; column++) {
TextureRegion textureRegion = textureRegions[row][column];
patternTableSprites[row][column] = new Sprite(textureRegion);
}
}
initializeMonochromePalette();
}
示例4: Trajectory
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public Trajectory(Orbiter orbiter) {
this.orbiter = orbiter;
int degreeIncrement = 10;
speed = 10;
Array<Orbiter> pathObjects = new Array<Orbiter>();
for(int i = 0; i < 360; i += degreeIncrement) {
Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
orbiterBlueprint.angle = i;
orbiterBlueprint.angularVelocity = speed;
orbiterBlueprint.radius = orbiter.getRadius();
orbiterBlueprint.xTilt = orbiter.getXTilt();
orbiterBlueprint.zTilt = orbiter.getZTilt();
Sprite trajectoryDot = new Sprite(Scene.pixelTexture);
Color color = new Color();
Color.rgba8888ToColor(color, orbiter.getColor());
trajectoryDot.setColor(color);
trajectoryDot.setSize(2, 2);
pathObjects.add(new Orbiter(trajectoryDot, orbiterBlueprint));
}
path = new Ring(pathObjects);
}
示例5: MakeMadany
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public MakeMadany(int sorah_no){
// TODO Auto-generated constructor stub
goza_name_texture = book.get_region(suar_state[sorah_no-1]?"makah":"madinah");
Goza_name_sprite = new Sprite(goza_name_texture);
height = tab_height ;
width = height;
Goza_name_sprite.setSize(width, height);
no = sorah_no ;
x = sorah_page_no_width+(sorah_tanzel_width-width)/2 ;
y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
text_y_deferance=2*tab_height/3;
surah_page_no = new TextActor(""+surah_page[no-1],
null,
sorah_page_no_width,
TextAlign.align_cinter, tab_no_text_scale,0,text_y_deferance+y);
}
示例6: GameState
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public GameState(String name, String tmx, StateManager manager) {
this.tmx = tmx;
setManager(manager);
if(name!=null)
this.name = name;
else
this.name = "";
sprites = new ObjectMap<String, Sprite>();
animations = new ObjectMap<String, Animation<String>>();
fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats
particle_effects = new ObjectMap<String, ParticleEffectPool>();
pvalues = new Array<String>();
time_scale = 1f;
shaders = new ObjectMap<String, ShaderProgram>();
svalues = new Array<String>();
}
示例7: SpaceObject
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public SpaceObject(Sprite sprite, int color) {
this.sprite = sprite;
this.color = color;
drawColor = new Color(color);
if(sprite != null) {
this.size = (int)sprite.getWidth();
}
}
示例8: testCloudJson
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
@Test
public void testCloudJson() {
Array<Orbiter> orbiters = new Array<>();
Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint();
orbiterBlueprint.angularVelocity = 70;
int cloudObjectsCount = 10;
for(int i = 0; i < cloudObjectsCount; i++) {
orbiters.add(new Orbiter(new Sprite(), orbiterBlueprint));
}
Cloud saveCloud = new Cloud(orbiters);
String cloudJson = json.toJson(saveCloud);
assertNotEquals("", cloudJson);
Cloud loadCloud = json.fromJson(Cloud.class, cloudJson);
assertNotEquals(null, loadCloud);
assertEquals(cloudObjectsCount, loadCloud.getCloudObjects().size);
assertEquals(70, loadCloud.getAngularVelocity());
}
示例9: GozaName
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public GozaName(int goza_no) {
// TODO Auto-generated constructor stub
goza_name_texture = book.get_region("s"+goza_no);
Goza_name_sprite = new Sprite(goza_name_texture);
width = sorah_name_width ;
height = tab_height ;
Goza_name_sprite.setSize(width, height);
no = goza_no ;
text_y_deferance=2*tab_height/3;
x = (sorah_page_no_width+sorah_tanzel_width+ayat_widht)+sorah_tab_book_mark_width*3 ;
y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1)));
no_of_surah = new TextActor(no+"",
null,
tab_no_width,
TextAlign.align_cinter,tab_no_text_scale,x+sorah_name_width, text_y_deferance+y);
}
示例10: setupSplashImage
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
private void setupSplashImage() {
DS.game.manager.load(splashImgFilename, Texture.class);
manager.finishLoading();
splashLogo = new Sprite(DS.game.manager.get(splashImgFilename, Texture.class));
splashLogo.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
double SCALE = DS.T_WIDTH/splashLogo.getWidth();
if(DS.app_orientation == DS.ORIENTATION.PORTRAIT) {
splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
} else {
SCALE = DS.T_HEIGHT/splashLogo.getHeight();
splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE));
}
int imgX = (int)(DS.T_WIDTH/2.0 - splashLogo.getWidth()/2.0);
int imgY = (int)(DS.T_HEIGHT/2.0 - splashLogo.getHeight()/2.0);
Gdx.app.debug(ID, "splshlogo Width: " + splashLogo.getWidth());
Gdx.app.debug(ID, "splshlogo Height: " + splashLogo.getHeight());
Gdx.app.debug(ID, "imgX: " + imgX);
Gdx.app.debug(ID, "imgY: " + imgY);
splashLogo.setPosition(imgX, imgY);
}
示例11: PlayAnimation
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public void PlayAnimation(Sprite sprite, Animation animation,
Rectangle newRegionOnTexture) {
if (animation == null && this.animation == null)
throw new GdxRuntimeException("No animation is currently playing.");
// If this animation is already running, do not restart it.
if (this.animation == animation)
return;
// Start the new animation.
this.animation = animation;
this.frameIndex = 0;
this.animationTimeline = 0.0f;
sprite.setRegionX((int) newRegionOnTexture.x);
sprite.setRegionY((int) newRegionOnTexture.y);
sprite.setRegionWidth((int) newRegionOnTexture.getWidth());
sprite.setRegionHeight((int) newRegionOnTexture.getHeight());
onAnimationChanged();
}
示例12: initilizeTileObject
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
/**
* Initialize position of sprite by the position of object from tiled map.
* If size 's values is not zero, the sprite will be scaled by the new size
*
* @param sprite
* the sprite will receive changes from tiled object
* @param object
* tiled object from tiled map
* @param size
*/
public void initilizeTileObject(Sprite sprite, TiledObject object,
float size) {
sprite.setX(object.x + object.width / 2);
sprite.setY(tileMapRenderer.getMapHeightUnits() - object.y
- object.height / 2);
if (size > 0) {
float s = object.width / size;
sprite.setScale(s);
}
}
示例13: 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);
}
示例14: 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);
}
示例15: Player
import com.badlogic.gdx.graphics.g2d.Sprite; //導入依賴的package包/類
public Player() {
super(0, 0);
this.x = (float) (GameScreen.earth.getXCenter() + radius * Math.sin(angle));
this.y = (float) (GameScreen.earth.getYCenter() + radius * Math.cos(angle));
img = new Sprite(new Texture(Gdx.files.internal("player.png")));
shoot = new Sound[4];
for (int i = 1; i <= shoot.length; i++) {
shoot[i - 1] = Gdx.audio.newSound(Gdx.files.internal("sound/shoot" + i + ".wav"));
}
}