我昨天开始使用andEngine,但我很困惑..我想为每个玩家制作一个自定义角色,所以我想在Assets / gfx中的应用程序内部创建一个数据库,如果玩家选择了另一个眼睛或鼻子,性格会改变。有没有办法建立这样的东西,而不是制作不同的精灵,并设置位置和所有这些。 (计算机上有一些游戏用我的应用程序做我想做的事情,如maplestory,LaTale,Gust online等)。
谢谢!
答案 0 :(得分:3)
我不确定它是以这种方式完成的(我从来没有使用它的游戏,也没试过它),但这是我现在想到的一个想法:
让我们说我们有一个角色外观编辑像maplestory的游戏。为了简单起见,角色只是一个圆圈,或者是一个二维球,你可以改变它的颜色和它的眼睛颜色。所以你有这些文件夹:
assets/gfx/circles
并且
assets/gfx/eyes
现在,我们假设我们有这个圈子:
我们有这些眼睛:
我们希望将它们结合起来。
你可以这样做:
BitmapTextureAtlas playerTextureAtlas = new BitmapTextureAtlas(256, 256 TextureOptions.BILINEAR_PREMULTIPLYALPHA);
TextureRegion playerTextureRegion = BitmapTextureAtlasTextureRegionFactory.createFromAsset(playerTextureAtlas, this, "circles/redcircle.png", 0, 0);
//By executing the next line, we place the eyes over the player texture area.
//There is NO need to keep a reference to the texture region this returns to us, because technically this one and playerTextureRegion are THE SAME - they both hold the same region in the texture (As long as they have the same sizes, of course)
BitmapTextureAtlasTextureRegionFactory.createFromAsset(playerTextureAtlas, this, "eyes/yelloweyes.png", 0, 0);
请记住 - 眼睛图像背景必须是透明的,所以它不会覆盖圆圈!使用TextureOptions
参数。我不确定我使用的那个是否会填满这个目的 - 也许另一个会。
最后,你应该保持眼睛的眼睛和圆圈大小相同,因为这样更容易测试它们是否合适。如果你让眼睛只是一个小矩形,你将不得不弄乱它,直到找到你应该将它放在圆圈上的地方。浪费时间......
现在,你可以加载不同的身体/眼睛/头发等等,放置它们,你就有了一个定制的玩家!
答案 1 :(得分:0)
我担心Jong的解决方案不起作用,至少在GLES1版本的AndEngine中是这样。当我试图用这种方式组合精灵时,最新的只是覆盖了它下面的任何东西。在这种情况下,只有眼睛会出现在屏幕上。