1
我正在使用AndEngine。如何更改添加到View AndEngine中的精灵的方向?
我有一个方法,将目标添加到screne。
这里是我的方法..
public void addTarget(){
/*
* We are determining the minimum and maximum y position for the targets to appear at then
* use the Random() class to generate a random number so the value of y is
* still on the screen while the x value replaces the sprite just before the right side or the screen.
*
*/
Random rand = new Random();
int x = (int) mCamera.getWidth() + mTargetTextureRegion.getWidth();
int minY = mTargetTextureRegion.getHeight();
int maxY = (int)(mCamera.getHeight() - mTargetTextureRegion.getHeight());
int rangeY = maxY - minY;
int y = rand.nextInt(rangeY) + minY;
Sprite target = new Sprite(x,y,mTargetTextureRegion.clone());
SceneMainScene.attachChild(target);
int minDuration = 2;
int maxDuration = 4;
int rangeDuration = maxDuration - minDuration;
int actualDuration = rand.nextInt(rangeDuration) + minDuration;
MoveXModifier mod = new MoveXModifier(actualDuration, target.getX(), - target.getWidth());
target.registerEntityModifier(mod);
TargetsToBeAdded.add(target);
它工作正常。我遇到的唯一问题是目标从左到右进入屏幕..我想改变这个,所以目标从上到下显示?
我不能在我的代码中找出我需要改变的地方吗?有什么建议么?
当我更换代码没有任何反应。精灵不会出现在屏幕上。当我把它切换回原来的工作。还有其他建议吗? –
精灵可能不会显示,因为它在屏幕之外创建并移出屏幕。尝试从你确定存在于窗口内的值中加入e,以检查运动是否正确。如果是这样,那么改变2点,记住一个引擎的坐标系 –
你可以在答案中张贴? –