Subscription
0
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning

## You're reading fromLearning LibGDX Game Development- Second Edition

Product type Book
Published in Jan 2015
Publisher Packt
ISBN-13 9781783554775
Pages 478 pages
Edition 1st Edition
Languages
Concepts
Authors (2):
Suryakumar B Nair
Andreas Oehlke
View More author details

Learning LibGDX Game Development Second Edition
Credits
www.PacktPub.com
Preface
1. Introduction to LibGDX and Project Setup 2. Cross-platform Development – Build Once, Deploy Anywhere 3. Configuring the Game 4. Gathering Resources 5. Making a Scene 6. Adding the Actors 7. Menus and Options 8. Special Effects 9. Screen Transitions 10. Managing the Music and Sound Effects 11. Advanced Programming Techniques 12. Animations 13. Basic 3D Programming 14. Bullet Physics Index

## Implementing the actor game objects

The gold coin, feather, and bunny head are some of our game objects. Each of our game objects inherits the `AbstractGameObject` class. The `AbstractGameObject` holds the attributes and functionalities for physics and collision detection.

First, let's make some preparations in `AbstractGameObject` and add a few functionalities for our upcoming physics and collision detection code.

Add the following import to `AbstractGameObject`:

`import com.badlogic.gdx.math.Rectangle;`

Then, add the following member variables and initialization code to the same class:

```public Vector2 velocity;
public Vector2 terminalVelocity;
public Vector2 friction;

public Vector2 acceleration;
public Rectangle bounds;

public AbstractGameObject () {
position = new Vector2();
dimension = new Vector2(1, 1);
origin = new Vector2();
scale = new Vector2(1, 1);
rotation = 0;
velocity = new Vector2();
terminalVelocity = new Vector2(1, 1);
friction = new Vector2();
acceleration = new Vector2...```
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 \$15.99/month. Cancel anytime