如何在lua和corona SDK中使用onComplete
2016-11-27 15:25:4
收藏:0
阅读:71
评论:1
我在解决问题时遇到了困难。我很高兴您能帮助我。我想让一个transition.to()在另一个之后发生。
local ball = display.newCircle(160,0,30)
local function move()
ball.x = display.contentWidth/2
ball.y = display.contentWidth-display.contentWidth-ball.contentWidth*2
transition.to(ball, {x=display.contentWidth/2, y=display.contentHeight*1.3, time=5000, onComplete=move2})
end
local function move2()
ball.x = display.contentWidth+ball.contentWidth/2
ball.y = 0-ball.contentWidth/2
transition.to(ball, {x=0-ball.contentWidth/2, y=display.contentHeight+ball.contentWidth/2, time = 5000})
--transition.to(ball,{x=160,y=240})
end
move()
点赞
评论区的留言会收到邮件通知哦~
推荐文章
- Lua 虚拟机加密load(string.dump(function)) 后执行失败问题如何解决
- 我想创建一个 Nginx 规则,禁止访问
- 如何将两个不同的lua文件合成一个 东西有点长 大佬请耐心看完 我是小白研究几天了都没搞定
- 如何在roblox studio中1:1导入真实世界的地形?
- 求解,lua_resume的第二次调用继续执行协程问题。
- 【上海普陀区】内向猫网络招募【Skynet游戏框架Lua后端程序员】
- SF爱好求教:如何用lua实现游戏内调用数据库函数实现账号密码注册?
- Lua实现网站后台开发
- LUA错误显式返回,社区常见的规约是怎么样的
- lua5.3下载库失败
- 请问如何实现文本框内容和某个网页搜索框内容连接,并把网页输出来的结果反馈到另外一个文本框上
- lua lanes多线程使用
- 一个kv数据库
- openresty 有没有比较轻量的 docker 镜像
- 想问一下,有大佬用过luacurl吗
- 在Lua执行过程中使用Load函数出现问题
- 为什么 neovim 里没有显示一些特殊字符?
- Lua比较两个表的值(不考虑键的顺序)
- 有个lua简单的项目,外包,有意者加微信 liuheng600456详谈,最好在成都
- 如何在 Visual Studio 2022 中运行 Lua 代码?

你的问题是什么?
尝试(已测试)
local ball = display.newCircle(160,0,30) local function move2() ball.x = display.contentWidth + ball.width * 0.5 ball.y = -ball.width * 0.5 transition.to(ball, {x=-ball.width * 0.5, y=display.contentHeight + ball.width * 0.5, time = 5000}) end local function move() ball.x = display.contentWidth * 0.5 ball.y = -ball.width * 2 transition.to(ball, {y=display.contentHeight * 1.3, time=5000, onComplete=move2}) end move()在使用函数名称之前,您必须声明具有相同名称的变量或将函数与体部分放置在您第一次使用它的位置之上。
如果您想在“move2”中的“transition.to”完成后再次调用“move”函数,请使用以下代码
local ball = display.newCircle(160,0,30) local move local function move2() ball.x = display.contentWidth + ball.width * 0.5 ball.y = -ball.width * 0.5 transition.to(ball, {x=-ball.width * 0.5, y=display.contentHeight + ball.width * 0.5, time = 5000, onComplete=move}) end function move() ball.x = display.contentWidth * 0.5 ball.y = -ball.width * 2 transition.to(ball, {y=display.contentHeight * 1.3, time=5000, onComplete=move2}) end move()请注意,您将获得无限转换。阅读有关Corona [博客](https://coronalabs.com/blog/2011/09/21/tutorial-scopes-for-functions/)中函数范围的更多信息。