有行被触摸,跳转到场景 ID 名为“Corona SDK”的场景。
2014-9-7 4:9:4
收藏:0
阅读:157
评论:2
我想要在行触摸时转到一个新的场景。我希望被触摸的行能够转到与id名称相同的文件名场景。我希望这不会太令人困惑。问题出现在函数rowtouch中。以下是我的代码。谢谢您的帮助。
local hike = {}
hike[1] = { name="Bell Canyon", difficulty="Easy" }
hike[2] = { name="Donut Falls", difficulty="Easy" }
hike[3] = { name="Hidden Peak", difficulty="Medium" }
hike[4] = { name="Dog Lake", difficulty="Easy" }
hike[5] = { name="Mary, Martha", difficulty="Easy" }
hike[6] = { name="Catherine", difficulty="Easy" }
function scene:create( event )
local sceneGroup = self.view
local function onRowRender( event )
local row = event.row
local id = row.index
row.nameText = display.newText( hike[id].name, 12, 0, native.systemFont, 45 )
row.nameText.anchorX = 0
row.nameText.anchorY = 0.5
row.nameText:setFillColor( 0 )
row.nameText.y = 50
row.nameText.x = 25
row.difficultyText = display.newText( hike[id].difficulty, 12, 0, native.systemFont, 24 )
row.difficultyText.anchorX = 0
row.difficultyText.anchorY = 0.5
row.difficultyText:setFillColor( 0.5 )
row.difficultyText.y = 110
row.difficultyText.x = 25
row.arrow = display.newText( ">", 12, 0, native.systemFont, 35 )
row.arrow.anchorX = 0
row.arrow.anchorY = 0.5
row.arrow:setFillColor( .5 )
row.arrow.y = 110
row.arrow.x = display.contentWidth - 50
row:insert( row.nameText )
row:insert( row.difficultyText )
row:insert( row.arrow )
return true
end
function RowTouch( event )
if event.phase == "release" then
composer.gotoScene( event.target.hike[id].name )
end
end
myTable = widget.newTableView
{
width = display.contentWidth,
height = display.contentHeight,
backgroundColor = { .47, .66, .53 },
topPadding = 0,
hideBackground = false,
onRowRender = onRowRender,
onRowTouch = RowTouch,
noLines = true,
}
for i=1, #hike do
myTable:insertRow{
rowHeight = 220,
isCategory = false,
lineColor = { .47, .66, .53 }
}
end
end
点赞
用户1870706
你可能应该在“徒步旅行”表中添加一个额外的字段:
hike[1] = { name="Bell Canyon", difficulty="Easy", sceneName="bellcanyon" }
然后
composer.gotoScene( hike[event.target.index].sceneName )
这样,您可以拥有一个用于人类阅读的显示名称和一个专门用于作曲家场景的字符串。
2014-09-08 01:16:17
评论区的留言会收到邮件通知哦~
推荐文章
- 如何将两个不同的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 代码?
- addEventListener 返回 nil Lua
- Lua中获取用户配置主目录的跨平台方法
尝试编写:
徒步旅行的名称中包含空格和逗号,不是最佳文件名。