Howdy, Stranger!

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

Parameter value not updating.

edited August 2015 in Questions Posts: 5

Hi!

The parameter maximum value (par1MaxVal) is not updating after rotating the screen or hiding the inspector.

The parameter.number must be in the setup ,but setup is just evaluate once.

Here is the code :

function setup()

    xr = 50   -- rect size 
    par1MaxVal = WIDTH-xr

    parameter.number("xs", 0,par1MaxVal,500,function(n) print("X = "..n) end )   

end


function draw()

    background(40, 40, 50)

    -- displays screen size at bottom right
    font("Futura-CondensedExtraBold")
    fontSize(15)
    fill(255, 255, 255, 146) 
    textAlign(CENTER)
    textWrapWidth()
    text(WIDTH .. "    " .. HEIGHT,WIDTH-40,20) 

    -- draw rectangle
    rect(xs,HEIGHT/2,xr,xr)
end

Have a good time

Tagged:

Comments

  • dave1707dave1707 Mod
    Posts: 8,496

    @shem Try this.

    function setup()
        xr = 50   -- rect size 
        wh=WIDTH
        par1MaxVal = WIDTH-xr
        parameter.clear()
        parameter.number("xs", 0,par1MaxVal,500,function(n) print("X = "..n) end )   
    end
    
    function draw()
        background(40, 40, 50)
        -- displays screen size at bottom right
        font("Futura-CondensedExtraBold")
        fontSize(15)
        fill(255, 255, 255, 146) 
        textAlign(CENTER)
        textWrapWidth()
        text(WIDTH .. "    " .. HEIGHT,WIDTH-40,20) 
        -- draw rectangle
        rect(xs,HEIGHT/2,xr,xr)
        if wh~=WIDTH then
            setup()
        end
    end
    
  • Posts: 1,976

    You can also use the function 'orientationChanged' to detect when the user rotates the screen, to update the parameters.

    function orientationChanged(newOrientation)
        ...
    end
    
  • Posts: 5

    Thanks Dave .

Sign In or Register to comment.