本文整理汇总了Java中org.andengine.entity.sprite.Sprite类的典型用法代码示例。如果您正苦于以下问题:Java Sprite类的具体用法?Java Sprite怎么用?Java Sprite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sprite类属于org.andengine.entity.sprite包,在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SplashScene
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
public SplashScene(TextureManager textureManager, AssetManager assetManager, VertexBufferObjectManager vbo, Camera camera) {
super();
this.setBackground(new Background(new Color(100, 100, 100)));
try {
splashTexture = new AssetBitmapTexture(textureManager, assetManager, "textures/splash.png", TextureOptions.BILINEAR);
splashTextureRegion = TextureRegionFactory.extractFromTexture(splashTexture);
splashTexture.load();
splash = new Sprite(0, 0, splashTextureRegion, vbo);
final float scale_factor = GameActivity.CAMERA_HEIGHT / splashTextureRegion.getHeight();
splash.setScale(scale_factor+0.1f);
splash.setPosition((camera.getWidth()) * 0.5f, (camera.getHeight()) * 0.5f);
this.attachChild(splash);
} catch (final IOException e) {
System.err.println("Error loading splash!");
e.printStackTrace(System.err);
}
}
示例2: pass
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
private void pass(Word word, final float wordX) {
//TODO: count success
Debug.d("ImageMatchGame : pass!");
GameSounds.play(GameSounds.COMPLETE);
this.winnings.add(word);
float available_width = (this.cardPane.getWidth()/this.max_choices);
float wordY = this.resultsPane.getHeight() + this.cardPane.getHeight() - 150;
ITiledTextureRegion sprite_region = this.game.wordSprites.get(word);
Sprite winning_sprite = new Sprite(wordX+(available_width/2), wordY, sprite_region.getTextureRegion(1), PhoeniciaContext.vboManager);
this.resultsPane.attachChild(winning_sprite);
winning_sprite.registerEntityModifier(new ParallelEntityModifier(
new ScaleModifier(0.5f, 2.0f, 1.0f),
new MoveYModifier(0.5f, wordY, 80),
new MoveXModifier(0.5f, wordX+(available_width/2), 40+(this.result_number*80))
));
this.result_number++;
}
示例3: fail
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
private void fail(Word word, final float wordX) {
//TODO: count failure
Debug.d("ImageMatchGame : fail!");
GameSounds.play(GameSounds.FAILED);
float available_width = (this.cardPane.getWidth()/this.max_choices);
float wordY = this.resultsPane.getHeight() + this.cardPane.getHeight() - 150;
ITiledTextureRegion sprite_region = this.game.wordSprites.get(word);
Sprite missed_sprite = new Sprite(wordX+(available_width/2), wordY, sprite_region.getTextureRegion(2), PhoeniciaContext.vboManager);
this.resultsPane.attachChild(missed_sprite);
missed_sprite.registerEntityModifier(new ParallelEntityModifier(
new ScaleModifier(0.5f, 2.0f, 1.0f),
new MoveYModifier(0.5f, wordY, 80),
new MoveXModifier(0.5f, wordX+(available_width/2), 48+(this.result_number*80))
));
this.result_number++;
}
示例4: putChar
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
/**
* Add the given letter to the next space in the spelling sequence for the word
* @param letter Letter to add to the proposed spelling
*/
public void putChar(Letter letter) {
if (this.cursorAt >= MAX_WORD_SIZE) {
Debug.d("Too many characters!");
return;
}
final int startX = 200 - (this.spelling.length * 35) + 35; // TODO: replace magic numbers
final ITextureRegion blockRegion = game.letterSprites.get(letter).getTextureRegion(0);
final Sprite character = new Sprite(this.charBlocksX[cursorAt], this.charBlocksY[cursorAt], blockRegion, PhoeniciaContext.vboManager);
this.buildPane.attachChild(character);
this.charSprites[this.cursorAt] = character;
this.spelling[cursorAt] = letter.chars[0];
this.cursorAt++;
this.game.playBlockSound(letter.phoneme);
}
示例5: pass
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
private void pass(Word word, final float wordX) {
Debug.d("NumberMatchGame : pass!");
GameSounds.play(GameSounds.COMPLETE);
this.winnings.add(word);
float available_width = (this.cardPane.getWidth()/this.max_choices);
float wordY = this.resultsPane.getHeight() + this.cardPane.getHeight() - 150;
ITiledTextureRegion sprite_region = this.game.wordSprites.get(word);
Sprite winning_sprite = new Sprite(wordX+(available_width/2), wordY, sprite_region.getTextureRegion(1), PhoeniciaContext.vboManager);
this.resultsPane.attachChild(winning_sprite);
winning_sprite.registerEntityModifier(new ParallelEntityModifier(
new ScaleModifier(0.5f, 2.0f, 1.0f),
new MoveYModifier(0.5f, wordY, 80),
new MoveXModifier(0.5f, wordX+(available_width/2), 40+(this.result_number*80))
));
this.result_number++;
}
示例6: fail
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
private void fail(Word word, final float wordX) {
Debug.d("NumberMatchGame : fail!");
GameSounds.play(GameSounds.FAILED);
float available_width = (this.cardPane.getWidth()/this.max_choices);
float wordY = this.resultsPane.getHeight() + this.cardPane.getHeight() - 150;
ITiledTextureRegion sprite_region = this.game.wordSprites.get(word);
Sprite missed_sprite = new Sprite(wordX+(available_width/2), wordY, sprite_region.getTextureRegion(2), PhoeniciaContext.vboManager);
this.resultsPane.attachChild(missed_sprite);
missed_sprite.registerEntityModifier(new ParallelEntityModifier(
new ScaleModifier(0.5f, 2.0f, 1.0f),
new MoveYModifier(0.5f, wordY, 80),
new MoveXModifier(0.5f, wordX + (available_width / 2), 48 + (this.result_number * 80))
));
this.result_number++;
}
示例7: pass
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
private void pass(Word word) {
//TODO: count success
Debug.d("wordmatch: pass!");
GameSounds.play(GameSounds.COMPLETE);
this.winnings.add(word);
ITiledTextureRegion sprite_region = this.game.wordSprites.get(word);
Sprite winning_sprite = new Sprite(this.cardPane.getWidth()/2, this.cardPane.getHeight() - 300, sprite_region.getTextureRegion(1), PhoeniciaContext.vboManager);
winning_sprite.setZIndex(foreground_sprite.getZIndex()+1);
this.resultsPane.attachChild(winning_sprite);
winning_sprite.registerEntityModifier(new ParallelEntityModifier(
new ScaleModifier(0.5f, 2.0f, 1.0f),
new MoveYModifier(0.5f, 300, 80),
new MoveXModifier(0.5f, this.resultsPane.getWidth()/2, 40+(this.result_number*80))
));
this.result_number++;
}
示例8: setEmblem
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
public void setEmblem(Sprite emblem) {
Debug.d("Setting emblem to "+emblem);
this.emblem = emblem;
this.emblem.setPosition(this.getWidth()*0.66f, this.getHeight()*0.66f);
this.emblem.setZIndex(this.getZIndex() + 1);
this.emblem.setScale(0.33f);
this.emblem.registerEntityModifier(
new LoopEntityModifier(
new SequenceEntityModifier(
new MoveYModifier(1f, this.emblem.getY(), this.emblem.getY() + 5),
new MoveYModifier(1f, this.emblem.getY()+5, this.emblem.getY())
)
)
);
this.attachChild(emblem);
}
示例9: onUpdateVertices
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Sprite pSprite) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float width = pSprite.getWidth(); // TODO Optimize with field access?
final float height = pSprite.getHeight(); // TODO Optimize with field access?
bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, 0);
bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, 0);
bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, 0);
bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, height);
bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, width);
bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, 0);
bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, width);
bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, height);
this.setDirtyOnHardware();
}
示例10: onUpdateVertices
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Sprite pSprite) {
final float[] bufferData = this.mBufferData;
final float x = 0;
final float y = 0;
final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
final float y2 = pSprite.getHeight(); // TODO Optimize with field access?
bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x;
bufferData[0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y;
bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x;
bufferData[1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y2;
bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x2;
bufferData[2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y;
bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X] = x2;
bufferData[3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y] = y2;
this.setDirtyOnHardware();
}
示例11: onUpdateVertices
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Sprite pSprite) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float width = pSprite.getWidth(); // TODO Optimize with field access?
final float height = pSprite.getHeight(); // TODO Optimize with field access?
bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, 0);
bufferData.put(0 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, 0);
bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, 0);
bufferData.put(1 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, height);
bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, width);
bufferData.put(2 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, 0);
bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_X, width);
bufferData.put(3 * UniformColorSprite.VERTEX_SIZE + UniformColorSprite.VERTEX_INDEX_Y, height);
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:22,代码来源:LowMemoryUniformColorSpriteVertexBufferObject.java
示例12: onUpdateVertices
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Sprite pSprite) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float x = 0;
final float y = 0;
final float x2 = pSprite.getWidth(); // TODO Optimize with field access?
final float y2 = pSprite.getHeight(); // TODO Optimize with field access?
final float xCenter = (x + x2) * 0.5f;
final float yCenter = (y + y2) * 0.5f;
bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x);
bufferData.put(0 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);
bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
bufferData.put(1 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y2);
bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, xCenter);
bufferData.put(2 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, y);
bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_X, x2);
bufferData.put(3 * Sprite.VERTEX_SIZE + Sprite.VERTEX_INDEX_Y, yCenter);
this.setDirtyOnHardware();
}
示例13: onManagedDraw
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
protected void onManagedDraw(final GLState pGLState, final Camera pCamera) {
this.mSpriteBatch.setIndex(0);
final Particle<UncoloredSprite>[] particles = this.mParticles;
for(int i = this.mParticlesAlive - 1; i >= 0; i--) {
final Sprite sprite = particles[i].getEntity();
/* In order to support alpha changes of the sprites inside the spritebatch,
* we have to 'premultiply' the RGB channels of the sprite with its alpha channel. */
final float alpha = sprite.getAlpha();
final float colorABGRPackedInt = ColorUtils.convertRGBAToABGRPackedFloat(sprite.getRed() * alpha, sprite.getGreen() * alpha, sprite.getBlue() * alpha, alpha);
this.mSpriteBatch.drawWithoutChecks(sprite, colorABGRPackedInt);
}
this.mSpriteBatch.submit();
this.mSpriteBatch.onDraw(pGLState, pCamera);
}
示例14: onUpdateColor
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateColor(final TiledSprite pTiledSprite) {
final float[] bufferData = this.mBufferData;
final float packedColor = pTiledSprite.getColor().getABGRPackedFloat();
final int tileCount = pTiledSprite.getTileCount();
int bufferDataOffset = 0;
for (int i = 0; i < tileCount; i++) {
bufferData[bufferDataOffset + 0 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 1 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 2 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 3 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 4 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferData[bufferDataOffset + 5 * TiledSprite.VERTEX_SIZE + Sprite.COLOR_INDEX] = packedColor;
bufferDataOffset += TiledSprite.TILEDSPRITE_SIZE;
}
this.setDirtyOnHardware();
}
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:22,代码来源:HighPerformanceTiledSpriteVertexBufferObject.java
示例15: onUpdateVertices
import org.andengine.entity.sprite.Sprite; //导入依赖的package包/类
@Override
public void onUpdateVertices(final Sprite pSprite) {
final FloatBuffer bufferData = this.mFloatBuffer;
final float width = pSprite.getWidth(); // TODO Optimize with field access?
final float height = pSprite.getHeight(); // TODO Optimize with field access?
bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, 0);
bufferData.put(0 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, 0);
bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, 0);
bufferData.put(1 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, height);
bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, width);
bufferData.put(2 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, 0);
bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_X, width);
bufferData.put(3 * UncoloredSprite.VERTEX_SIZE + UncoloredSprite.VERTEX_INDEX_Y, height);
this.setDirtyOnHardware();
}