Howdy, Stranger!

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

Please Help! Anyone!

I am working on my programm and I need your help. How can you help? Just tell me the command that stops the class from working or that stops the program for a several amount of time. Also don't forget to tell me it's arguments.

Everyone, Have a nice day.

Comments

  • Posts: 28
    close()
    

    ?

  • A notice to Kire: the command that you given isn't what I want. I need a command that only makes the programm to sleep, not to crash!

  • dave1707dave1707 Mod
    Posts: 7,907

    @HappyProgrammer11 You don't stop the program from working. Codea runs in a constant loop and the way you stop something from executing is to not execute its function. You use an if statement to control when a function is called. If you have instances of a class that draws several things on the screen, then use the if statement and some variable to call or not call those instances.

  • dave1707dave1707 Mod
    Posts: 7,907

    Here's an example to show or not show a sprite

    function setup()
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        text("tap screen to show or not show a sprite",WIDTH/2,HEIGHT-100)
        if show then
            sprite("Planet Cute:Character Horn Girl",WIDTH/2,HEIGHT/2)
        end    
    end
    
    function touched(t)
        if t.state==BEGAN then
            show=not show
        end
    end
    
  • Posts: 28

    So you want the program to be in some pause/standby?

  • Again a personal message to Kire: Yes, but I want it to be in the standby for a fixed amount of time.

  • IgnatzIgnatz Mod
    Posts: 5,396

    to pause a program for X seconds, try this

    function pause(X)
        paused=ElapsedTime+X
    end
    
    --then set up your draw program like this
    
    function draw()
        --don't draw anything if paused
        if paused then 
            if ElapsedTime<paused then return else paused=nil end
        end
        --your other draw code goes here
    end
    
    --then to pause your program for 5 seconds, write this line
    pause(5)
    
  • @Ignatz Big Thanks! That works!

  • @Ignatz Please, tell me how to use this inside a loop or another function instead for the draw function.

  • IgnatzIgnatz Mod
    Posts: 5,396

    You have to tell your draw function not to draw during a pause.

    That's what my code does.

Sign In or Register to comment.