错误:尝试索引全局"云"

时间:2015-11-09 07:41:58

标签: lua sdk corona

为什么我看不到云图像,并且当我放置x和y坐标时,它是一个零值,最后我怎么能上升并随机重新定位?

local storyboard = require("storyboard")
    local scene = storyboard.newScene()
    local physics = require "physics"
    physics.start( )
    physics.setGravity(0, 0)
    --physics.setDrawMode( "hybrid" )
    local LEFT = 100
    local CENTER = display.contentCenterX
    local RIGHT = display.contentWidth - 100

问题出在这里。我试图改变imges和各种编码但它失败了

    function scene:createScene(event)
        local screenGroup = self.view

        cloud = display.newImage( "cloud.jpeg")
        cloud.x = 200
        cloud.y = 900

        back = display.newImage( "sky.png" )
        back.x = display.contentWidth/2
        back.y = display.contentHeight/2
        screenGroup:insert(back)



    end



   local function handleSwipe( event )
          if event.phase == "moved" then
               local dX = event.x - event.xStart
               print(event.x, event.xStart, dX)
               if dX > 10 then

                    local spot = RIGHT
                    if event.target.x == LEFT then
                        spot = CENTER
                   end
                   transition.to( event.target, {time=350, x = spot } )
              elseif dX  < -10 then

                   local spot = LEFT
                    if event.target.x == RIGHT then
                        spot = CENTER
                    end
                    transition.to( event.target, {time=350, x = spot } )
              end
           end
           return true
    end


    function scene:enterScene(event)

      object = display.newImage( "diver.png", display.contentCenterX,  display.contentHeight/1.7, 25 )


      object:addEventListener( "touch", handleSwipe )


     end

    function scene:exitScene( event )

    end 

    function scene:destroyScene( event )
    end

    scene:addEventListener( "createScene", scene )
    scene:addEventListener( "enterScene", scene )
    scene:addEventListener( "exitScene", scene )
    scene:addEventListener( "destroyScene", scene )

    return scene

任何人都可以提供帮助吗?

1 个答案:

答案 0 :(得分:0)

我认为"cloud.jpeg"所在的文件夹中没有main.lua。否则告诉我哪个行错误。