Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Construct 2 Game Development by Example

You're reading from   Construct 2 Game Development by Example Learn how to make games for multiple platforms with Construct 2.

Arrow left icon
Product type Paperback
Published in Jun 2014
Publisher
ISBN-13 9781849698061
Length 230 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
John Bura John Bura
Author Profile Icon John Bura
John Bura
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Getting Started with Construct 2 FREE CHAPTER 2. Inputs and Controls 3. Variables and Arrays 4. Game Mechanics 5. Making a Simple Shooter 6. Making a Tower Defense Game 7. Making a Puzzle Physics Game 8. Exporting Your Game A. Where to Go from Here
Index

Adding the enemy


Adding enemies is a great way to add game complexity and fun. Let's add an enemy that moves towards the player. Go ahead and add an enemy to the screen. I sized the enemy 30, 30 and named the sprite Enemy. This is what your layout should look like:

Next, we need to go to our event sheet and add an Every tick event.

Once you have an event sheet that looks like the preceding screenshot, you can add an action for the Enemy sprite, such as Rotate toward position. Type Player.X in the X box and Player.Y in the Y box. This sets the position to the player's X and Y locations, and it is shown in the following screenshot:

Once you have done that, add another action. This time, we need to move the enemy forward. Navigate to Add action | Enemy | Move forward, as shown in the following screenshot:

We do have to move the enemy forward a certain distance. In this case, we will set the distance to 1. You can set the distance to another number if you wish.

Your event sheet should look like the...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image