lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hi all-

This is one of the first programs I've built from scratch and am really excited about it, except that no one else at my school knows Lua to help me trouble shoot.  I'm using Xcode 7.3 beta 3.  I'm sure there are better ways to code it, I'm just a novice!  I've been looking for other tutorials that might be good to use with my students (who have Codea) but haven't found a lot that teach - more that are just references.

Anyhow, how it's working in the simulator is different from how it works on the iPad.  I have a rectangle printing each time to cover the prior score and in the simulator, it puts up one "cover rectangle" and then the new score.  But when I build it on the iPad mini itself, it seems to write 2 scores at the same time so it looks messy.  Any help/suggestions? Any reasons why it would work differently in the simulator than the iPad?

Thanks so much for your time.  I don't know any one else that knows Lua :)

>From Main.lua

function setup()

    --Set the viewer to fullscreen

    displayMode( FULLSCREEN )

    total = 0

    perry = {points=50}

    bridge = {points=100}

    acadia = {points=150}

    print("Width ", WIDTH)

    print("Height ", HEIGHT)


function draw()



    --Score words

    text("Score", WIDTH/2, 650)


    --Perry's Rectangle

    fill( 150, 0, 150,255)

    rect( 0, 0, 300, 500 )

    --Bridge Rectangle

    fill(0,150, 150, 255)


    --Acadia Rectangle

    fill(150, 150, 0, 255)

    rect(600,0,WIDTH, 500)

    --Bridge Words


    text("Perry's", 100, 450)

    text("Bridge", 450, 450)

    text("Acadia", 750, 450)

    fill(100, 100, 200, 255)

    ellipse (CurrentTouch.x, CurrentTouch.y, 100, 100)

    if CurrentTouch.state == BEGAN then

        if CurrentTouch.x <=300

            then total = total + perry.points

            else if CurrentTouch.x >=600

                then total = total + bridge.points

                else total = total + acadia.points



       --Rectangle to cover previous score


        rect(WIDTH/2-100, 500, 200, 100)



        text(total, WIDTH/2, 550)




Technology Integrator
Oceanside High School (East & West)
Owls Head Central School
Gilford Butler School<>