Play lab - having an actor (ghost) move continuously


#1

Hello!

I have a student playing in Play Lab. She’s trying to have her ghost move continuously throughout the screen. We haven’t had any luck finding a video to help with this. Can anyone offer advice?

Thanks
Karin and student
:slight_smile:


#3

Not sure I’m understanding exactly what you want, but inside the draw loop do something like this

ghost.x = ghost.x + 1; // moves ghost across the screen in a predictable path
if (ghost.x > 400){
ghost.x = 0; // start over when ghost gets to right edge of screen
}

OR

// to move the ghost pseudo randomly on the screen do the following inside the draw loop
ghost.x = randomNumber(0,400); // sets ghost x to random number somewhere on the screen
ghost.y = randomNumber(0,400); // sets ghost y to random number somewhere on the screen


#4

I was thinking game lab not play lab, so this might not work.