gpt4 book ai didi

java - AndEngine - 一般 2D 横向卷轴问题

转载 作者:行者123 更新时间:2023-11-29 05:52:38 25 4
gpt4 key购买 nike

我刚开始使用 AndEngine,很难找到好的教程/文档。我正在制作一个 2D 横向卷轴游戏,其中平台和墙壁是随机生成的。用户可以控制玩家的移动(跳跃、向前走)。

我有几个一般性问题:

如何让视差背景仅在玩家移动时滚动?

我是否应该将物理世界引力设置为空,并将引力添加到实际需要它的每个单独对象?我不希望重力影响 float 平台/墙壁。

如何在播放器移动时为其设置动画(动画行走)?

进行碰撞检测(玩家/敌人、玩家/墙壁/平台等)的最佳方法是什么?

抱歉,一下子问了很多。感谢您的帮助!

最佳答案

这是关于碰撞过滤器的:herehere
如果你询问整体碰撞,那么你可以用 Sprite 来做:heroSprite.collidesWith(enemySprite);
如果碰撞问题得到解决,那么您可以仅为您的英雄(跳跃)设置重力和 body (物理 body )。或者制作必要的过滤器并将墙壁制作为静态物体(固定物体不受重力影响)。

动画英雄:
加载纹理:
private ITiledTextureRegion hero;

BuildableBitmapTextureAtlas heroTextureAtlas = new BuildableBitmapTextureAtlas(gameController.getTextureManager(), 256, 256, TextureOptions.NEAREST);

this.hero = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(heroTextureAtlas, gameController.getAssets(), "hero.png", 3, 4);

try {
heroTextureAtlas.build(new BlackPawnTextureAtlasBuilder<IBitmapTextureAtlasSource, BitmapTextureAtlas>(0, 0, 0));
heroTextureAtlas.load();
} catch (TextureAtlasBuilderException e) {
Debug.e(e);
}

并将其用于动画:heroSprite.animate( ); - 方法参数选择多,看你需要什么。

抱歉我的英语不好,希望对您有所帮助。

关于java - AndEngine - 一般 2D 横向卷轴问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13342147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com