播放和停止 spritesheet 使用 lua 进行 corona
我创建了一个连续播放的精灵表,
local sheet3 = sprite.newSpriteSheet( "sample.png",400,317)
local spriteSet3 = sprite.newSpriteSet(sheet3, 1, 8)
sprite.add( spriteSet3, "puma", 1, 8, 1000, 0 ) -- play 8 frames every 1000 ms
local instance3 = sprite.newSprite( spriteSet3 )
instance3.x = 2* display.contentWidth / 4 + 30
instance3.y = baseline - 5
instance3.xScale = .5
instance3.yScale = .5
instance3:prepare("puma")
instance3:play()
正如我们所知,精灵表循环显示图像序列。我想在图像序列完成一个循环后停止播放。
有人知道我该怎么做吗?或者至少给我提供任何链接来帮助我解决这个问题?
I have created a sprite sheet which plays continuously,
local sheet3 = sprite.newSpriteSheet( "sample.png",400,317)
local spriteSet3 = sprite.newSpriteSet(sheet3, 1, 8)
sprite.add( spriteSet3, "puma", 1, 8, 1000, 0 ) -- play 8 frames every 1000 ms
local instance3 = sprite.newSprite( spriteSet3 )
instance3.x = 2* display.contentWidth / 4 + 30
instance3.y = baseline - 5
instance3.xScale = .5
instance3.yScale = .5
instance3:prepare("puma")
instance3:play()
As we know spritesheet shows image sequence in loop. I want to stop play of image sequence after it completes one loop.
Anybody know how can i do this? or at least provide me any link to help me out to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您首先定义动画时,您设置是否循环:
http://developer.anscamobile.com/reference/index/spriteadd
或者,如果您需要以编程方式调整动画(即循环直到玩家执行某些操作)然后您可以设置事件侦听器并在循环事件发生时调用暂停():
http://developer.anscamobile.com/reference/index/spriteinstanceaddeventlistener
When you define the animation in the first place you set whether or not to loop:
http://developer.anscamobile.com/reference/index/spriteadd
Alternatively if you need to adjust the animation programmatically (ie. loop until the player does something) then you can set an event listener and call pause() when the loop event happens:
http://developer.anscamobile.com/reference/index/spriteinstanceaddeventlistener