具有多个图像/实体的ParallaxLayer按顺序滚动 [英] ParallaxLayer with multiple images/entities scrolling in Sequential manner
问题描述
我是andengine的新手,正在尝试使用我从以下示例中获得的ParallaxLayer类女巫编写基本的Sidescroller游戏:
Hi I am new to andengine and trying to code a basic sidescroller game using the ParallaxLayer class witch I got from the following example :http://www.andengine.org/forums/features/parallaxlayer-t5390.html I followed the example and it works.
我的问题是如何依次显示例如3个图像(Sun_Stage.png,Moon_Stage.png Dark_stage.png)作为可滚动背景...首先滚动到完成Sun_stage.png,然后滚动到下一个阶段女巫是Moon_Stage.png吗?
My question is how would I display for example 3 images(Sun_Stage.png, Moon_Stage.png Dark_stage.png) in sequential manner as a scrollable background... First scroll until Sun_stage.png is finnished and then scroll the next stage witch is Moon_Stage.png?
玩家将在行走视差层时从Sun_Stage开始,从而滚动图像....当Sun_Stage完成(达到其末端宽度)时,下一个Stage Moon_Stage应该可见并滚动?
The Player would start in the Sun_Stage while he walks the parallaxlayer would scroll the image.... when the Sun_Stage is finished(reached its end width) then the next Stage Moon_Stage should be visible and scroll?
希望我有道理?我不知道是否还有另一种方式...我基本上只是想编写一款永远不会以变化的可滚动背景结尾的Sidesroller游戏.
Hope I make sense? I don't know if there's another way of doing this... I basically just want to code a sidescroller game that's never ending with scrollable background that changes.
任何帮助将不胜感激.
推荐答案
Entity parent = new Entity();
attachChild(parent);
Sprite mountainsSprite = new Sprite(0, 0, WIDTH, HEIGHT, mountainsTextureRegion, mEngine.getVertexBufferObjectManager());
mountainsSprite.setPosition(0, 0);
parent.attachChild(mountainsSprite);
Sprite starsSprite = new Sprite(0, 0, WIDTH, HEIGHT, starsTextureRegion, mEngine.getVertexBufferObjectManager());
starsSprite.setPosition(mountainsSprite.getX()+ mountainsSprite.getWidth(), 0);
parent.attachChild(starsSprite);
ParallaxLayer parallaxLayer = new ParallaxLayer(camera, true, 4000);
backgroundParallax.setParallaxChangePerSecond(8);
backgroundParallax.setParallaxScrollFactor(1);
backgroundParallax.attachParallaxEntity(new ParallaxEntity(10, parent, true));
在这里我添加了所需的精灵以按顺序移动到一个实体.然后我将该实体作为parallaxEntity设置为Parallax background
Here what i have done is added the required sprites to move in sequence to an entity.Then I made this entity as parallaxEntity to Parallax background
这篇关于具有多个图像/实体的ParallaxLayer按顺序滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!