【发布时间】:2015-11-23 14:30:13
【问题描述】:
我正在尝试使用 Corona SDK 找出一个简单的真假测验应用程序。现在我可以使用 text= myData.ScoreCount 计算正确答案 请正确:
local textoPontuacao = {
text= myData.ScoreCount,-- correct score is counting
x = ganhou.x + 310,
y = ganhou.y - 47,
width = 700,
font = native.systemFontBold,
fontSize = 36,
}
local t=50 -- total questions
local c=textoPontuacao -- textoPontuacao counts correct answer
local pc=(c/t)*100
local r
if pc >=60 and pc<70 then
r = "Not Bad!"
elseif pc >=70 and pc<80 then
r = "Good Match!"
elseif pc >=80 and pc<95 then
r = "Very Good Match!"
elseif pc >=95 and pc<101 then
r = "Excellent!"
else
r = "You have to Think"
end
local textoPon = display.newText( r )-- normally if i use textoPontuacao instead of r, it prints correct Answer.
textoPon:setFillColor( 1,1,1 )
sceneGroup:insert(textoPon)
现在我想从 if else 语句中打印字符串值而不是正确答案。如果我使用 textoPontuacao 进行打印,则会显示正确答案。有人帮助解决这个问题将不胜感激。而且我也需要将正确答案转换为百分比,但不清楚如何?我是 lua 和 corona SDK 的新手,只是想定制一个简单的游戏。
【问题讨论】:
-
究竟是什么不在这里工作?您似乎正在将表格除以一个数字。这会给你一个错误吗?
-
嗨,谢谢,我收到一个错误,尝试在本地'c'(表值)中执行算术,它是表--------本地 textoPontuacao = { text= myData .ScoreCount,--正确的分数是计数x = ganhou.x + 310, y = ganhou.y - 47, width = 700, font = native.systemFontBold, fontSize = 36, }
-
是的,那是因为您试图将表格除以数字。你的意思是
local c = t.text在那里算数吗? -
是的,我现在试过了,它说一个错误,尝试索引一个本地't'(一个数字值)
-
抱歉,我的意思是
local c = textoPontuacao.text或local c = myData.ScoreCount或只是local pc = (myData.ScoreCount / t) * 100。