我昨天开始使用 andEngine,但我很困惑..我想为每个玩家制作一个自定义角色,所以我想在应用程序内的 Assets/gfx 中创建一个数据库,例如,如果玩家选择了不同的角色眼睛或 Nose ,性格就会改变。有没有什么方法可以构建这样的东西,而无需制作不同的 Sprite 并设置位置等等。 (计算机上有一些游戏可以实现我想要使用我的应用程序执行的操作,例如 Maplestory、LaTale、Gust online 等)
谢谢!
最佳答案
我不确定它是这样完成的(我从来没有在游戏中使用过它,也没有尝试过),但现在我想到了一个想法:
假设我们有一款像冒险岛一样具有角色外观编辑功能的游戏。为了简单起见,角色只是一个圆圈或二维球,您可以更改它的颜色和眼睛的颜色。所以你有这些文件夹:
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
参数。我不确定我使用的那个是否可以满足这个目的 - 也许另一个可以。
最后,你应该保持眼睛和圆圈的大小相同,因为这样更容易测试它们是否合适。如果你把眼睛做成一个小矩形,你就得把它弄乱,直到找到应该将它放置在圆上的位置。浪费时间...
现在,您只需加载不同的 body /眼睛/头发等,放置它们,您就得到了一个定制的播放器!
关于android - AndEngine 自定义 Sprite ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8626021/