From the course: HTML5 Game Development with Phaser
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Bunny movement
- The entities we created aren't really doing anything yet. We can fix that through Phaser's tween system in coordination with the animation states that we have assigned to them upon creation. So inside of our game JS file, inside of build bunnies, we've added a number of different animations. What we want to do is have these animations actually trigger off at certain points when we're manually tweening this bunny movement. So to do that I've got a number of functions that I'm going to paste into our code editor right here, so that we can go over them. The first one is assign bunny movement. So assign bunny movement will actually, inside of build bunnies, right after play, save this, assign bunny movement, and pass in the current bunny instance in there. That'll get the bunnies moving right away. This assign bunny movement function does a number of different things. So we have a position and a delay. Both of these different variables are going to be based on a random number, so the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.