Corona - 如何使精灵表与动态图像分辨率兼容
Corona 有一种创建图像的方法,该图像将根据设备分辨率动态显示:
img = display.newImageRect("image.png", 100, 100)
很好,但是如果所有图像都在 Sprite 表中(为了性能而推荐),该怎么办?然后你必须做这样的事情来显示图像:
local data = require("sheet1")
local tileSheet = sprite.newSpriteSheetFromData("sheet1.png", data.getSpriteSheetData())
local tileSet = sprite.newSpriteSet(tileSheet, 1, 3)
local img = sprite.newSprite(tileSet)
img.currentFrame = 1
How do you createdynamicsizedimagesfromspritesheets?
Corona has a method for creating images that will be displayed dynamically based on device resolution:
img = display.newImageRect("image.png", 100, 100)
Great, but what if all your images are in a sprite sheet, which is recommended for performance? Then you have to do something like this to display the image:
local data = require("sheet1")
local tileSheet = sprite.newSpriteSheetFromData("sheet1.png", data.getSpriteSheetData())
local tileSet = sprite.newSpriteSet(tileSheet, 1, 3)
local img = sprite.newSprite(tileSet)
img.currentFrame = 1
How do you create dynamically sized images from sprite sheets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 display.contentScaleX http://developer.anscamobile.com/reference/index/displaycontentscalex
这是http://developer.anscamobile.com/forum/2010/12/08/dynamic-retina-spritesheets-heres-how
use display.contentScaleX http://developer.anscamobile.com/reference/index/displaycontentscalex
here's how http://developer.anscamobile.com/forum/2010/12/08/dynamic-retina-spritesheets-heres-how
这是我调整背景动画大小的方法。它由 2 个帧组成,每个帧为 794 x 446。它需要是全屏、横向模式。请参阅下面的步骤 6。
Here's how I resized my background animation. It consisted of 2 frames, each 794 x 446. It needed to be full-screen, landscape mode. Refer to step 6 below.