Book Image

Learning Construct 2

By : Aryadi Subagio
Book Image

Learning Construct 2

By: Aryadi Subagio

Overview of this book

Table of Contents (17 chapters)
Learning Construct 2
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Learning random generation


I defined random generation at the beginning of this chapter and now I will discuss it in a technical fashion. We will create the obstacles at a random position on the scrolling ground. So, first we will make the ground scroll.

Making the ground scroll

To make the ground scroll, we need to first make it move in one direction at all times; to do this, we need to use a movement behavior. We'll use a behavior that is different from the 8 Direction behavior; to make an object move in one direction, we will use the Bullet behavior. Add this to the ground object, just like we added the 8 Direction behavior to the plane object. It doesn't matter to which of the two instances of the ground object you add the behavior; it will be added to all instances of this object.

Now, the ground will automatically move, so we will make it move in the direction we want it to. First, we will set the Set angle property from the Bullet behavior's property to No because the ground doesn't...