【问题标题】:Lua Equal To issue in CoronaLua Equal To 在 Corona 中发行
【发布时间】:2016-01-09 13:22:15
【问题描述】:

我目前正在开发一个 android 应用程序,但我遇到了一个问题,即电晕没有注册 fish1 位于 display.contentWidth/3 + 20。当fish1 位于display.contentWidth/3 + 20 时,会生成newBubble,它会出现在鱼所在的x 轴上。

bubbleDivision = display.contentWidth/3 -- How many times the Bubbles will appear
print (bubbleDivision)

if fish1.x == display.contentWidth/3 + 20 then
    newBubble = display.newImage("testBubble.png")
    print "Spawned"

    newBubble.x = fish1.x       
end

【问题讨论】:

    标签: android lua coronasdk


    【解决方案1】:

    很可能是浮点错误。使用math.floormath.ceil,无论哪个适用/合适。

    bubbleDivision = math.floor( display.contentWidth / 3 )
    if math.floor(fish1.x) == bubbleDivision + 20 then
    

    【讨论】:

    • 谢谢,但没用。我尝试添加它,但之后没有任何效果
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-08
    相关资源
    最近更新 更多