• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ParallaxBackground类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.andengine.entity.scene.background.ParallaxBackground的典型用法代码示例。如果您正苦于以下问题:Java ParallaxBackground类的具体用法?Java ParallaxBackground怎么用?Java ParallaxBackground使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ParallaxBackground类属于org.andengine.entity.scene.background包,在下文中一共展示了ParallaxBackground类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
    }
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:41,代码来源:GameScene.java


示例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);
}
 
开发者ID:sm4,项目名称:FlyingDandelion,代码行数:16,代码来源:GameScene.java


示例3: SceneManager

import org.andengine.entity.scene.background.ParallaxBackground; //导入依赖的package包/类
public SceneManager(SimpleBaseGameActivity context, ResourceManager resourceManager, ParallaxBackground parallaxBackground){
	this.mContext = context;	
	this.mResourceManager = resourceManager;
	this.mParallaxBackground = parallaxBackground;
}
 
开发者ID:deano2390,项目名称:OpenFlappyBird,代码行数:6,代码来源:SceneManager.java


示例4: onCreateScene

import org.andengine.entity.scene.background.ParallaxBackground; //导入依赖的package包/类
@Override
protected Scene onCreateScene() {				

	mBackground = new ParallaxBackground(82/255f, 190/255f, 206/255f){

		float prevX = 0;
		float parallaxValueOffset = 0;

		@Override
		public void onUpdate(float pSecondsElapsed) {

			switch(GAME_STATE){

			case STATE_READY:
			case STATE_PLAYING:
				final float cameraCurrentX = mCurrentWorldPosition;//mCamera.getCenterX();

				if (prevX != cameraCurrentX) {

					parallaxValueOffset +=  cameraCurrentX - prevX;
					this.setParallaxValue(parallaxValueOffset);
					prevX = cameraCurrentX;
				}
				break;
			}		

			super.onUpdate(pSecondsElapsed);
		}
	};

	mSceneManager = new SceneManager(this, mResourceManager, mBackground);
	mScene = mSceneManager.createScene();	

	mScene.setOnSceneTouchListener(new IOnSceneTouchListener() {

		@Override
		public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
			if(pSceneTouchEvent.isActionDown()){

				switch(GAME_STATE){

				case STATE_READY:
					startPlaying();
					break;

				case STATE_PLAYING:
					mSceneManager.mBird.flap();
					break;

				case STATE_DEAD:
					//restartGame();
					break;	
				}								
			}
			return false;
		}
	});		
	
	updateScore();

	return mScene;
}
 
开发者ID:deano2390,项目名称:OpenFlappyBird,代码行数:63,代码来源:MainActivity.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DelegationTokenManagerException类代码示例发布时间:2022-05-22
下一篇:
Java State类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap