story board........ PLEASE HELP ME!

please figure out my problem i dont get it!!

-----------------[code]-----------------

display.setStatusBar(display.HiddenStatusBar)

local storyboard = require (“storyboard”)

local scene = storyboard.newScene()

local physics = require(“physics”)

physics.start()

–== ------------[CREATESCENE]----------- ==–

function scene:createScene(event)

    local bg = display.newImage(“bg.png”)

    

    local ball

    

    local winFlag = display.newImage(“flag.png”)

    

    local platform

    local ps1

    

    local ps2

    

    local winningFloor = display.newImage(“floor.png”)

    local floor = display.newImage(“invisbleWall1.png”)

    

    local lWall = display.newImage(“invisbleWall2.png”)

    

    local rWall = display.newImage(“invisbleWall2.png”)

    

    local ceiling = display.newImage(“invisbleWall1.png”)

floor.type = “walls”

lWall.type = “walls”

rWall.type = “walls”

ceiling.type = “walls”

floor.y = 320

ceiling.y = 0

rWall.x = 481

lWall.x = 0

physics.addBody(floor,“static”)

physics.addBody(ceiling,“static”)

physics.addBody(rWall,“static”)

physics.addBody(floor,“static”)

local gameIsOver = false

local rotateSpeed = 3.5

local rotateSpeedHole = 10

local ballBounce = 0.6 

local platformFirstScale = 0.9

winningFloor:setReferencePoint(display.CenterReferencePoint)

winningFloor.x = 420

winningFloor.y = 296

winningFloor.type = “win”

physics.addBody(winningFloor,“static”)

winFlag:setReferencePoint(display.CenterReferencePoint)

winFlag.x = 420

winFlag.y = 260

winFlag.xScale = 0.7

winFlag.yScale = 0.7

end

–== ----------[ENTERSCENE]---------- ==–

function scene:enterScene(event)

–== ****************[IMPORTING OBJRCTS]**************** ==--  

  ball = display.newImage(“ball.png”)

  platform = display.newImage(“platform_normal.png”)

  ps1 = display.newImage(“platform_small.png”)

  ps2 = display.newImage(“platform_small.png”)

platform:setReferencePoint(display.CenterReferencePoint)

platform.x = 108

platform.y = 40

platform.xScale = platformFirstScale

platform.yScale = platformFirstScale

physics.addBody( platform, “static”, { friction=0.5, bounce=0.3 } )

ps1:setReferencePoint(display.CenterReferencePoint)

ps1.x = 60

ps1.y = 20

ps1.xScale = platformFirstScale

ps1.yScale = platformFirstScale

physics.addBody( ps1, “static”, { friction=0.5, bounce=0.3 } )

ps2:setReferencePoint(display.CenterReferencePoint)

ps2.x = 155

ps2.y = 20

ps2.xScale = platformFirstScale

ps2.yScale = platformFirstScale

physics.addBody( ps2, “static”, { friction=0.5, bounce=0.3 } )

ball:setReferencePoint(display.CenterReferencePoint)

ball.x = 50

ball.y = 90

ball.xScale = 0.14

ball.yScale = 0.14

ball.type = “ball”

ball:addEventListener(“touch”, startPhysics)  

platform:addEventListener(“touch”, startDrag)

ps1:addEventListener(“touch”, startDrag)

ps2:addEventListener(“touch”, startDrag)

ball.collision = ballCollision

ball:addEventListener(“collision”, ball)

return true

end

–== ----------[EXITSCENE]---------- ==–

function scene:exitScene(event)

  

end

–== ----------[DESTROYSCENE]---------- ==–

function scene:destroyScene(event)

  

  end

– --==************************[Function]****************************+±- –

local function gameOver()

    ball.isVisible = true

end

local function ballCollision(self, event)

  if event.phase == “began” then

    rotateSpeed = 0

    if(event.target.type == “ball” and event.other.type == “walls”) then

      gameOver()

      end

    if event.target.type == “ball” and event.other.type == “win” then

      levelComplete()

      end

    end

    

    if event.phase == “moved” then

      rotateSpeed = 3.5

      end

    

    if event.phase == “ended” then

      rotateSpeed = 3.5

      end

  end

  

  

  

  

  

local function levelComplete(event)

    ball:setLinearVelocity(0,0)

    end

  

local function rotateBall(event)

    ball.rotation = ball.rotation + rotateSpeed

    end

  

local function startDrag( event )

    

        local t = event.target

        local phase = event.phase

        if “began” == phase then

                display.getCurrentStage():setFocus( t )

                t.isFocus = true

                – Store initial position

                t.x0 = event.x - t.x

                t.y0 = event.y - t.y

                

                          t = transition.to( t, { xScale=1, yScale=1} )

                

                – Make body type temporarily “kinematic” (to avoid gravitional forces)

                event.target.bodyType = “kinematic”

        elseif t.isFocus then

                if “moved” == phase then

                        t.x = event.x - t.x0

                        t.y = event.y - t.y0

                elseif “ended” == phase or “cancelled” == phase then

                        display.getCurrentStage():setFocus( nil )

                        t.isFocus = false

                        t:removeEventListener(“touch”,startDrag)

                        t:addEventListener(“touch”,rotatePlatform)

                end

        end

        – Stop further propagation of touch event!

        return true

end

   

   

  

local function startPhysics(event)

  local phase = event.phase

  if phase == “began” then

    Runtime:addEventListener(“enterFrame”,rotateBall)

    platform:removeEventListener(“touch”, rotatePlatform)

    platform:removeEventListener(“touch”, startDrag)

    ps1:removeEventListener(“touch”, rotatePlatform)

    ps1:removeEventListener(“touch”, startDrag)

    ps2:removeEventListener(“touch”, rotatePlatform)

    ps2:removeEventListener(“touch”, startDrag)

    physics.addBody(ball,{bounce = ballBounce ,radius = 18})

  end

  end

  

local function rotatePlatform(event)

  

  

  

  

        local t = event.target

        local phase = event.phase

        

        if (phase == “began”) then

                display.getCurrentStage():setFocus( t )

                t.isFocus = true

                – Store initial position of finger

                t.x1 = event.x

                t.y1 = event.y

                

        elseif t.isFocus then

                if (phase == “moved”) then

                        t.x2 = event.x

                        t.y2 = event.y

                        

                        angle1 = 180/math.pi * math.atan2(t.y1 - t.y , t.x1 - t.x)

                        angle2 = 180/math.pi * math.atan2(t.y2 - t.y , t.x2 - t.x)

                        print("angle1 = "…angle1)

                        rotationAmt = angle1 - angle2

                        --rotate it

                        t.rotation = t.rotation - rotationAmt

                        print ("t.rotation = "…t.rotation)

                        

                        t.x1 = t.x2

                        t.y1 = t.y2

                        

                elseif (phase == “ended”) then

                      t:addEventListener(“touch”, startDrag)

                        display.getCurrentStage():setFocus( nil )

                        t.isFocus = false

                      t:removeEventListener(“touch”, rotatePlatform)

                end

        end

        return true

end

-------------------[EVENTLISTENERS]----------------

  scene:addEventListener( “createScene”, scene )

  scene:addEventListener( “enterScene”, scene )

  scene:addEventListener( “exitScene”, scene )

  scene:addEventListener( “destroyScene”, scene )

  

  return scene

----------[done]-------------

error is :

File: assertion failed!

Assertion failed!

 

stack traceback:

    [C]: ?

    [C]: in function ‘assert’

    ?: in function ‘getOrCreateTable’

    ?: in function ‘addEventListener’

    ?: in function ‘addEventListener’

    …rs/erezcsillag/Documents/ballGameCORONA/levelone.lua:107: in function <…rs/erezcsillag/Documents/ballGameCORONA/levelone.lua:71>

    ?: in function ‘dispatchEvent’

    ?: in function <?:1076>

    (tail call): ?

    ?: in function <?:172>

    ?: in function <?:218>

 

 

 

 

 

 

 

 

WHAT THE HELL IS THIS!!?!!??!?!??!

@erez9901, I only glanced at your code, so there may be a lot more issues, but one thing I see missing right away is local screenGroup = self.view  (or equivalent) in scene:createScene function.

Take a close look at how the storyboard is structured in Sample Code that comes bundled with Corona SDK:

CoronaSDK > SampleCode > Interface > Storyboard

Good luck.

Naomi

thanx i will try that!

Why are all your functions after destroyScene?   They are usually placed at the top before the storyboard functions. 

You have a scoping problem.  When you call:

ball:addEventListener(“touch”, startPhysics)

your module doesn’t know what startPhysics is yet.   (probably the same problem for the next addEventListener too).

Those functions need to be moved to the top somewhere above scene:createScene().

MYYYYY GOOOOOD THANX THAT SOLVED IT THANKS SO YOU MUCH!!!

@erez9901, I only glanced at your code, so there may be a lot more issues, but one thing I see missing right away is local screenGroup = self.view  (or equivalent) in scene:createScene function.

Take a close look at how the storyboard is structured in Sample Code that comes bundled with Corona SDK:

CoronaSDK > SampleCode > Interface > Storyboard

Good luck.

Naomi

thanx i will try that!

Why are all your functions after destroyScene?   They are usually placed at the top before the storyboard functions. 

You have a scoping problem.  When you call:

ball:addEventListener(“touch”, startPhysics)

your module doesn’t know what startPhysics is yet.   (probably the same problem for the next addEventListener too).

Those functions need to be moved to the top somewhere above scene:createScene().

MYYYYY GOOOOOD THANX THAT SOLVED IT THANKS SO YOU MUCH!!!