本文整理汇总了Java中org.andengine.entity.scene.Scene.attachChild方法的典型用法代码示例。如果您正苦于以下问题:Java Scene.attachChild方法的具体用法?Java Scene.attachChild怎么用?Java Scene.attachChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.scene.Scene
的用法示例。
在下文中一共展示了Scene.attachChild方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateScene
import org.andengine.entity.scene.Scene; //导入方法依赖的package包/类
@Override
protected Scene onCreateScene() {
Logger.log(TAG, "onCreateScene");
Scene scene = new Scene();
ITexture background = mResources.getTexture("background.jpg");
ITextureRegion region = TextureRegionFactory.extractFromTexture(background);
Logger.log(TAG, "region: x - " + region.getTextureX() + "; y - " + region.getTextureY() +
"; width - " + region.getWidth() + "; height - " + region.getHeight());
Sprite backgroundSprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, region, getVertexBufferObjectManager());
scene.attachChild(backgroundSprite);
ITexture fish = mResources.getTexture("fish.png");
ITextureRegion fishRegion = TextureRegionFactory.extractFromTexture(fish);
Sprite fishSprite = new Sprite(CAMERA_WIDTH / 2, CAMERA_HEIGHT / 2, fishRegion, getVertexBufferObjectManager());
scene.attachChild(fishSprite);
return scene;
}
示例2: setGameScene
import org.andengine.entity.scene.Scene; //导入方法依赖的package包/类
private void setGameScene() {
gameScene = new Scene();
gameScene.setOnAreaTouchTraversalFrontToBack();
final IOnSceneTouchListener sceneTouchListener = currentGame.getOnSceneTouchListener();
if (sceneTouchListener != null) {
gameScene.setOnSceneTouchListener(sceneTouchListener);
}
loadPhysics(currentGame);
for (int i = 0; i < LAYER_COUNT; i++) {
final Entity layer = new Entity();
layer.setZIndex(i);
gameScene.attachChild(layer);
}
loadHUD(currentGame);
loadScene(currentGame);
mEngine.setScene(gameScene);
MusicManager.pause();
music.play();
}
示例3: Bird
import org.andengine.entity.scene.Scene; //导入方法依赖的package包/类
public Bird(float birdXOffset, float birdYOffset, VertexBufferObjectManager mVertexBufferObjectManager, Scene mScene) {
this.mBirdXOffset = birdXOffset;
this.mBirdYOffset = birdYOffset;
mSprite = new AnimatedSprite(mBirdXOffset, mBirdYOffset, 55.8f, 40, mBirdTextureRegion, mVertexBufferObjectManager);
mSprite.setColor(Color.YELLOW);
mSprite.animate(115);
mSprite.setZIndex(2);
mScene.attachChild(mSprite);
}
示例4: PipePair
import org.andengine.entity.scene.Scene; //导入方法依赖的package包/类
public PipePair(int mOpeningHeight,
VertexBufferObjectManager mVertexBufferObjectManager, Scene mScene) {
super();
this.mOpeningHeight = mOpeningHeight;
this.mVertexBufferObjectManager = mVertexBufferObjectManager;
this.mScene = mScene;
PIPE_Y_OFFSET = MainActivity.CAMERA_WIDTH - 50 + (int)(Math.random() * ((200 - 50 ) + 1));
int rand_number = (int)( Math.random() * 7 ) ;
int min_offset = 100 + (int)(Math.random() * ((200 - 100 ) + 1));
int coin_height = 30 + (int)( Math.random() * 800 ) ;
// upper pipe
mUpperPipeSection = new Sprite(PIPE_Y_OFFSET + pipediffs[rand_number], 0, pipeSectionWidths[rand_number], mOpeningHeight-145, mUpperPipeSectionTexture, mVertexBufferObjectManager);
mUpperPipeSection.setZIndex(1);
mScene.attachChild(mUpperPipeSection);
mUpperPipe = new Sprite(PIPE_Y_OFFSET, mOpeningHeight-145, pipeWidths[rand_number], 20, mUpperPipeTexture, mVertexBufferObjectManager);
mUpperPipe.setZIndex(1);
mScene.attachChild(mUpperPipe);
//lower pipe
mLowerPipe = new Sprite(PIPE_Y_OFFSET, mOpeningHeight+125 , pipeWidths[rand_number], 20, mLowerPipeTexture, mVertexBufferObjectManager);
mLowerPipe.setZIndex(1);
mScene.attachChild(mLowerPipe);
mLowerPipeSection = new Sprite(PIPE_Y_OFFSET + pipediffs[rand_number] , mOpeningHeight+145, pipeSectionWidths[rand_number], MainActivity.FLOOR_BOUND - mOpeningHeight - 145 , mLowerPipeSectionTexture, mVertexBufferObjectManager);
mLowerPipeSection.setZIndex(1);
mScene.attachChild(mLowerPipeSection);
coin = new Sprite( PIPE_Y_OFFSET - min_offset , coin_height , 40 , 40 , coinTexture, mVertexBufferObjectManager);
coin.setZIndex(1);
mScene.attachChild(coin);
coindestroyed = false;
mScene.sortChildren();
mUpperPipeSection.setRotationCenterY(0) ;
}