Corona - 从精灵表创建常规显示对象?
这是显示图像的正常方式:
local img = display.newImage("image.png");
但是将所有图像放在一个大图像中并从 Zwoptex 导出不是可以节省内存吗?有关于从精灵表创建动画精灵的文档,但是如果只从精灵表中提取单个图像呢?
local zwoptexData = require "sheet1"
local data = zwoptexData.getSpriteSheetData()
//then what?
This is normal way of displaying an image:
local img = display.newImage("image.png");
But doesn't it save memory to put all your images in one large image and export from Zwoptex? There is documentation for creating animated sprites from sprite sheets, but what about just pulling a single image from a sprite sheet?
local zwoptexData = require "sheet1"
local data = zwoptexData.getSpriteSheetData()
//then what?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从平铺表制作静态图像的命令如下所示:
假设工作表上的所有平铺都是 64x64,但您可以轻松地调整这些命令以使用精灵表数据。需要注意的重要事项是 newSprite() 和 .currentFrame
编辑:您评论说您无法弄清楚如何使用精灵数据,因此修改后的代码是
要了解其工作原理,请参阅
http://developer.anscamobile.com/reference/sprite-sheets
The commands to make a static image from a tile sheet look like this:
That assumes all the tiles on the sheet are 64x64 but you could easily adapt those commands to use your sprite sheet data. The important things to note are newSprite() and .currentFrame
EDIT: You commented that you can't figure out how to use sprite data with this, so the modified code is
To learn how this works refer to
http://developer.anscamobile.com/reference/sprite-sheets