当前位置: 首页>>代码示例>>Java>>正文


Java Scene.attachChild方法代码示例

本文整理汇总了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;
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:19,代码来源:GameActivity.java

示例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();
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:22,代码来源:AbstractGameActivity.java

示例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);
		
	}
 
开发者ID:sunnyshah2894,项目名称:Flappy-Guy,代码行数:13,代码来源:Bird.java

示例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) ;
	

}
 
开发者ID:sunnyshah2894,项目名称:Flappy-Guy,代码行数:47,代码来源:PipePair.java


注:本文中的org.andengine.entity.scene.Scene.attachChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。