subject: Have Codea a Pause mode?
Can I do this…
i have an object (for example, cat)
cat position: (x,20)
the cat go ten steps to the right → x=x+10
pause, waiting, (2seconds) —> Code?
the cat go ten steps to the left → x=x-10
(without complex controlstructures, it’s for children)
If you want a simple method you can look at tween.delay().
tween.delay(2,callback_func)
@AnnSophie If you’re looking for something simple to move a sprite around the screen and pause, try this. The sprite is controlled by what’s in the “dirTab” table. It contains 3 values per entry. The first is the x direction, the second is the y direction, and the third is the number of seconds to pause after that move. In the example below, the sprite starts at x=100 y=100. In the “dirTab”, the first move is 200 for x, 20 for y, and a pause for 5 seconds. It will then move -100 for x, and -10 for y, and pause for 4 seconds. It will then move -5 for x, 200 for y, and pause for 6 seconds. After that it will then start at the beginning of the table and continue those moves. You can add more values to the “dirTab” as long as they’re vec3(x,y,pause). If the sprite goes off the screen, it will move to the center and continue.
displayMode(FULLSCREEN)
function setup()
dirTab={
vec3(200,20,5),
vec3(-100,-10,4),
vec3(-5,200,6)
}
x=100
y=100
xcount=0
ycount=0
offset=0
delay=0
end
function draw()
background(40, 40, 50)
fill(255)
if x<0 or x>WIDTH or y<0 or y>HEIGHT then
x=WIDTH/2
y=HEIGHT/2
end
sprite("Planet Cute:Character Princess Girl",x,y)
direction()
end
function direction()
if xcount==0 and ycount==0 then
if delay>0 then
delay=delay-(1/60)
text("PAUSED",WIDTH/2,HEIGHT-50)
return
end
offset=offset+1
if offset>#dirTab then
offset=1
end
delay=dirTab[offset].z
xcount=dirTab[offset].x
ycount=dirTab[offset].y
end
if xcount~=0 then
if dirTab[offset].x>0 then
x=x+1
if xcount>0 then
xcount = xcount - 1
end
end
if dirTab[offset].x<0 then
x=x-1
if xcount<0 then
xcount = xcount + 1
end
end
end
if ycount~=0 then
if dirTab[offset].y>0 then
y=y+1
if ycount>0 then
ycount = ycount - 1
end
end
if dirTab[offset].y<0 then
y=y-1
if ycount<0 then
ycount = ycount + 1
end
end
end
end
This could easily be done with tween.delay.
I feel like it would be more appropriate to use Scratch for this, though…