gpt4 book ai didi

android - 行触摸了 id 名称为 "Corona SDK"的 gotoScene

转载 作者:行者123 更新时间:2023-11-29 02:41:35 25 4
gpt4 key购买 nike

我正在尝试进入行触摸的新场景。我希望被触摸的行转到具有与 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

最佳答案

您可能应该在“远足”表中添加一个额外的字段:

hike[1] = { name="Bell Canyon",    difficulty="Easy",  sceneName="bellcanyon" }

然后

composer.gotoScene( hike[event.target.index].sceneName )

这样你就可以有一个供人类阅读的显示名称和一个专供 Composer 场景转到的字符串。

关于android - 行触摸了 id 名称为 "Corona SDK"的 gotoScene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25706992/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com