Howdy, Stranger!

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

I need help with setContext() and Codea Crashes.

AnatolyAnatoly Mod
in Questions Posts: 831

This code:

function CreateGraphic:formula()
    --[[
    Function is called like this in 'draw':

    local img = self:formula()
    sprite(img, (WIDTH+225)/2, HEIGHT/2+50, 700, 450)
    ]]

    img = image(450, 300)
    setContext(img)
    fill(127, 127, 127, 255)
    rect(0, 0, 450, 300)
    setContext()
    return img
end

It's definitely this function, because when commenting it, it won't crash Codea. :neutral:

Comments

  • IgnatzIgnatz Mod
    Posts: 5,396

    The function looks like it calls itself, so it goes round and round until it crashes

  • AnatolyAnatoly Mod
    Posts: 831

    What do you mean by "calls itself"?
    I am not calling the function anywhere else...

  • AnatolyAnatoly Mod
    Posts: 831

    Instead of making another function, I have put the code part in 'draw', and it was still crashing:

        -- Show Diagramm
        img = image(450, 300)
        setContext(img)
        fill(127, 127, 127, 255)
        rect(0, 0, 450, 300)
        setContext()
        sprite(img, (WIDTH+225)/2, HEIGHT/2+50, 700, 450)
    

    Still crashes :/

  • IgnatzIgnatz Mod
    Posts: 5,396

    Why are you using setContext every time you draw?

  • AnatolyAnatoly Mod
    Posts: 831

    Okey, Fixed, creating new images 60 times a miliseconds is crashing Codea.

    Just made it being elements...

  • Posts: 1,272

    Hi,

    Try putting your image generation in setup then just sprite the image in draw:


    displayMode(OVERLAY) function setup() img = image(450, 300) setContext(img) fill(127, 127, 127, 255) rect(0, 0, 449, 299) setContext() end function draw() background(50,50,50,255) sprite(img, WIDTH/2, HEIGHT/2) end

    Make sure the size of your img is the same size as the rectangle.

    Bri_G

  • AnatolyAnatoly Mod
    Posts: 831

    But it should be updated automatically...

Sign In or Register to comment.