本文整理汇总了Java中org.andengine.entity.scene.background.ParallaxBackground.attachParallaxEntity方法的典型用法代码示例。如果您正苦于以下问题:Java ParallaxBackground.attachParallaxEntity方法的具体用法?Java ParallaxBackground.attachParallaxEntity怎么用?Java ParallaxBackground.attachParallaxEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.andengine.entity.scene.background.ParallaxBackground
的用法示例。
在下文中一共展示了ParallaxBackground.attachParallaxEntity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: populateScene
import org.andengine.entity.scene.background.ParallaxBackground; //导入方法依赖的package包/类
@Override
public void populateScene() {
AbstractGameActivity activity = getActivity();
if (activity == null) {
return;
}
ResourcesManager manager = activity.getResourcesManager();
TextureRegion backgroundRegion = TextureRegionFactory.extractFromTexture(manager.getTexture("gfx/grass.jpg"));
ParallaxBackground background = new AutoParallaxBackground(0, 0, 0, 5);
background.attachParallaxEntity(new ParallaxBackground.ParallaxEntity(0, new Sprite(
0, activity.getCameraHeight() / 2,
backgroundRegion, manager.getVertexBufferObjectManager())));
setBackground(background);
setBackgroundEnabled(true);
/* BitmapTextureAtlas mBitmapTextureAtlas = new BitmapTextureAtlas(
activity.getTextureManager(), 256, 256, TextureOptions.BILINEAR);
TiledTextureRegion mPlayerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(
mBitmapTextureAtlas, activity.getApplicationContext(), "gfx/hero.png", 0, 0, 4, 2);
AnimatedSprite player = new AnimatedSprite(100, 100, mPlayerTextureRegion, manager.getVertexBufferObjectManager());
player.animate(new long[]{100, 100, 100}, 5, 7, true);*/
TextureRegion playerRegion = TextureRegionFactory.extractFromTexture(manager.getTexture("gfx/player.png"));
mPlayerSprite = new Sprite(activity.getCameraWidth() / 2, activity.getCameraHeight() / 2,
playerRegion, manager.getVertexBufferObjectManager());
mPlayerSprite.setScale(3);
attachChild(mPlayerSprite);
Random random = new SecureRandom();
for (int i = 0; i < 5; i++) {
TextureRegion bombRegion = TextureRegionFactory.extractFromTexture(manager.getTexture("gfx/bomb.png"));
int width = random.nextInt(activity.getCameraWidth());
int height = random.nextInt(activity.getCameraHeight());
//noinspection ObjectAllocationInLoop
Sprite sprite = new Sprite(width, height, bombRegion, manager.getVertexBufferObjectManager());
mBombsSprite.add(sprite);
attachChild(sprite);
}
}
示例2: createBackground
import org.andengine.entity.scene.background.ParallaxBackground; //导入方法依赖的package包/类
private void createBackground() {
pb = new ParallaxBackground(0.75f, 0.83f, 0.95f);
Entity clouds = new Rectangle(0, 0, 1000, 800, vbom);
clouds.setAnchorCenter(0, 0);
clouds.setAlpha(0f);
clouds.attachChild(new Sprite(100, 500, res.cloudRegion, vbom));
clouds.attachChild(new Sprite(300, 700, res.cloudRegion, vbom));
clouds.attachChild(new Sprite(500, 600, res.cloudRegion, vbom));
clouds.attachChild(new Sprite(800, 730, res.cloudRegion, vbom));
ParallaxEntity pe = new ParallaxEntity(-0.2f, clouds);
pb.attachParallaxEntity(pe);
setBackground(pb);
}