Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Set Starting Tilt as global variable [answered]

edited November 2011 in Questions Posts: 2

Hi folks,

I'm pretty new to Codea and I'm trying to play around with the Tilt feature.

I try to set the starting Gravity.y as an global variable. becaus everybody is holding his iPad in another way.

My 1. idea was to

GravityYStart = Gravity.y

My 2. ideas was:

GravityYStart = 0

function setup()
       GravityYStart = Gravity.y
end

But it seems not to work as i thought it was.

Any ideas?

Tagged:

Comments

  • SimeonSimeon Admin Mod
    Posts: 4,957

    Gravity is not initialised when setup() is called – we'll have to fix that. For now you can initialise it as follows:

    --
    function setup()
        GravityYStart = 0
    end
    
    function draw()
        if GravityYStart == 0 then
            GravityYStart = Gravity.y
        end
    end
    

    Just so you are aware, the Gravity vector is normalised to be relative to screen orientation. So if you are holding your iPad upside down, the gravity vector will still point "down" relative to the screen.

  • thanks very much. now it is working as intended.

    I'm just playing around with the bit invader and changing the movement from touch to tilt. So it's intended that when I'm holding

Sign In or Register to comment.