O'Reilly logo

Developing Mobile Games with Moai SDK by Francisco Tufro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating information

We need to write something into those textboxes. What we'll do in this case is call an update method in HUD periodically, so that it can refresh the data and print it on the screen:

function HUD:update ()
    local x, y = Character.prop:getScl ()
  1. We get the scale that we used to set the character's direction, and store it in a local variable x:
        if x > 0 then
            self.leftRightIndicator:setString ( "Left" )
        else
            self.leftRightIndicator:setString ( "Right" )
        end
  2. If you remember what we did before, this should be pretty clear. In order to turn right we scaled the character's prop to -1 in the x axis, and to 1 to turn the character to the left. So that's what we're doing here. If the x value of the scale is positive, then we're facing left. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required