android - AndEngine 自定义 Sprite

标签 android character andengine sprite

我昨天开始使用 andEngine,但我很困惑..我想为每个玩家制作一个自定义角色,所以我想在应用程序内的 Assets/gfx 中创建一个数据库,例如,如果玩家选择了不同的角色眼睛或 Nose ,性格就会改变。有没有什么方法可以构建这样的东西,而无需制作不同的 Sprite 并设置位置等等。 (计算机上有一些游戏可以实现我想要使用我的应用程序执行的操作,例如 Maplestory、LaTale、Gust online 等)

谢谢!

最佳答案

我不确定它是这样完成的(我从来没有在游戏中使用过它,也没有尝试过),但现在我想到了一个想法:

假设我们有一款像冒险岛一样具有角色外观编辑功能的游戏。为了简单起见,角色只是一个圆圈或二维球,您可以更改它的颜色和眼睛的颜色。所以你有这些文件夹:

assets/gfx/circles

assets/gfx/eyes

现在,假设我们有这个圈子:

Red circle

我们有这样的眼睛:

Yellow 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/

相关文章:

android - 为什么任何应用程序中的 admob 广告都无法显示

android - 为什么我看不到使用此 Activity 的 ProgressDialog?

string - 使用perl计算字符串中的大写字母

java - 将 XML 嵌入到 SOAP 请求的 CDATA 部分时出现解析错误

C 中的字符矩阵声明和打印

android - 是否有关于如何使用 Naver 的 Line URL SCHEME 的示例或教程?

android - 如何使用 Flutter "saf"包进行文件操作(创建/写入/更新/删除文件)

android - onManagedUpdate 方法和 touchevent 处理之间的区别?

java - 碰撞检测在低 FPS 时失败(Andengine)

android - 带有标签的 AndEngine 菜单项