SlideShare a Scribd company logo
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Game Development with AndEngine GLES2
Daniela da Cruz

Computação Móvel
Licenciatura em Engenharia de Jogos Digitais
Instituto Politécnico do Cávado e do Ave
October 28, 2013

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Introduction
Basic Elements
Camera
Engine
Scene
Entity
Texture  TextureRegion
Creating the rst scene with AndEngine
Handling Scene touches

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Introduction

AndEngine is a free open source OpenGL Android game engine,
developed by Nicolas Gramlich.
AndEngine is currently available in two avors: GLES1 and GLES2.
GLES2, as you might guess, supports OpenGL ES 2.0.

https://github.com/nicolasgramlich
http://www.matim-dev.com/

Latest version:
Tutorials:

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Introduction
AndEngine Advantages:

It has a complete 2-D scene graph, with a very easy-to-use
API.
It works great with the Android activity lifecycle.
It has a number of extensions that can be added as plugins.
It has multi-touch support.
It's free and open-source.
AndEngine Disadvantages:

The API is undocumented.
Sometimes slower in comparison to other engines.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Basic Elements

To create a scene we need 3 basic elements:
Camera
Engine
Scene

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Camera

Camera

Since all is based in a game scene we need to setup a camera:

Camera(pX, pY, pWidth, pHeight);
pX and pY are the coordinates for the origin of the camera
pWidth and pHeight are the dimensions, in pixels, of the
camera

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Engine

Engine
In the engine we dene which camera will be used on the scene:

EngineOptions(pFullscreen, pScreenOrientation,
pResolutionPolicy(pWidth, pHeight), pCamera)
pFullscreen determines whether the game will be play full
screen or not
pScreenOrientation, here we can choose between
LANDSCAPE and PORTRAIT
pResolutionPolicy is the ratio of our Engine (same values as in
Camera)
pCamera is the camera object

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Scene

Scene
The Scene class is the root container for all objects to be drawn on
the screen.
A Scene has a specic amount of Layers, which themselves can
contain a (xed or dynamic) amount of Entities.
There are subclasses, like the CameraScene/HUD/MenuScene that
are drawing themselves to the same position of the Scene no
matter where the camera is positioned to.
HUD (heads-up display)  usage for example for score (it has

to be all the time in the same position, follow camera
changes).

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Entity

Entity
An

Entitiy is an object that can be drawn, like Sprites, Rectangles,

Text or Lines.
An Entity has a position/rotation/scale/color/etc.
Sprite - entity with texture
TiledSprite - entity with tiled texture, you may switch between
tiles.
AnimatedSprite - extension of the TiledSprite, you may
animate tiles in specied intervals.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Texture  TextureRegion

Texture  TextureRegion

A Texture is a 'image' in the memory of the graphics chip.
A TextureRegion denes a rectangle on the Texture. A
TextureRegion is used by Sprites to let the system know what part
of the big Texture the Sprite is showing.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Creating the rst scene with AndEngine

The rst le created by the project is an

Activity.

And the rst thing to do in our project is to change the class that
this Activity extends.
Instead of extending the Activity class, we want to make it extend a
class called SimpleBaseGameActivity.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Creating the rst scene with AndEngine

The SimpleBaseActivity class provides additional callbacks and
contains the code to make AndEngine work with the Activity life
cycle.
Each callback that it provides is used for a specic purpose. As
soon as you extend this class, we will have to override three
functions.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Extending SimpleBaseGameActivity
onCreateEngineOptions  this function is where you create

an instance of the engine. Every activity that the game uses
will have its own instance of the engine that will run within the
activity lifecycle.
onCreateResources  this is the function where we load all

the resources that the activity requires into the the VRAM.
onCreateScene  this function is called after the above two

callbacks are executed. This is where we create the scene for
our game and use all the textures that we previously loaded
into memory.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Extending SimpleBaseGameActivity

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Creating a Sprite
When creating a Sprite object, we pass four parameters:
xCoordinate: Denes the X-position of the sprite.
yCoordinate: Denes the Y-position of the sprite.
TextureRegion: Denes what part of the texture the sprite will
use to draw itself.
VertexBuerObjectManager: Think of a vertex buer as an
array holding the coordinates of a texture. These coordinates
are passed to the OpenGL ES pipeline and ultimately dene
what will be drawn. A VertexBuerObjectManager holds all
the vertices of all the textures that need to be drawn on the
scene.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Attaching a Sprite to a Scene

To attach a sprite, to a dierent entity, for example to the Scene,
we have to simply call

attachChild

method:

anyEntity.attachChild(yourSprite);

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Handling Scene touches
Lets say we want to execute a certain action, every time the player
touches the screen.
We have to implement

IOnSceneTouchListener

interface.

Add unimplemented method.

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Handling Scene touches

The methods that identify if an event occurred or not are:

isActionDown(), isActionMove(), isActionUp().
Now all you have to do is to register this touch listener in a certain
scene:

scene.setOnSceneTouchListener(this);

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
Introduction

Basic Elements

Creating the rst scene with AndEngine

Handling Scene touches

Handling Entity touches
The problem of this approach is that it will handle every event that
occurs in the whole scene.
If we want to handle touch events of specic entities, we will need
to implement the method

onAreaTouch()

(the parameters are the

event and its coordinates).

Game Development with AndEngine GLES2
Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave

More Related Content

PDF
Unity introduction for programmers
PDF
The Ring programming language version 1.7 book - Part 53 of 196
PPTX
Unity3D Programming
PDF
Presentación Unity
PPTX
PDF
Cocos2d 소개 - Korea Linux Forum 2014
PDF
PPTX
Academy PRO: Unity 3D. Environment
Unity introduction for programmers
The Ring programming language version 1.7 book - Part 53 of 196
Unity3D Programming
Presentación Unity
Cocos2d 소개 - Korea Linux Forum 2014
Academy PRO: Unity 3D. Environment

What's hot (20)

PDF
Forest assassin 2 d platformer game
PDF
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
PDF
The Basics of Unity - The Game Engine
PPT
Introduction to Unity3D Game Engine
PPTX
Unity 3D, A game engine
PPTX
Game Project / Working with Unity
PPTX
WP7 HUB_XNA
DOCX
GameMaker Workflow
PDF
Unity Programming
PDF
The Ring programming language version 1.2 book - Part 36 of 84
PPTX
Unity 3D game engine seminar
DOCX
Y1 gd level_designworkflow
PDF
PDF
Unity Introduction
PDF
The Ring programming language version 1.8 book - Part 55 of 202
PPTX
Game Development with Unity
PPTX
Academy PRO: Unity 3D. Scripting
PDF
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
PDF
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
PDF
Game Engine Overview
Forest assassin 2 d platformer game
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
The Basics of Unity - The Game Engine
Introduction to Unity3D Game Engine
Unity 3D, A game engine
Game Project / Working with Unity
WP7 HUB_XNA
GameMaker Workflow
Unity Programming
The Ring programming language version 1.2 book - Part 36 of 84
Unity 3D game engine seminar
Y1 gd level_designworkflow
Unity Introduction
The Ring programming language version 1.8 book - Part 55 of 202
Game Development with Unity
Academy PRO: Unity 3D. Scripting
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Game Engine Overview
Ad

Viewers also liked (7)

PDF
Android Lesson 2
PPTX
Programming android game using and engine
PPTX
Android Application Component: BroadcastReceiver Tutorial
PDF
Intent in android
PDF
Android intents
PDF
Android: Intent, Intent Filter, Broadcast Receivers
PDF
Android Lesson 3 - Intent
Android Lesson 2
Programming android game using and engine
Android Application Component: BroadcastReceiver Tutorial
Intent in android
Android intents
Android: Intent, Intent Filter, Broadcast Receivers
Android Lesson 3 - Intent
Ad

Similar to Game Development with AndEngine (20)

PPTX
Game Development Session - 3 | Introduction to Unity
PPTX
Android Game Minisyonize
PDF
Unreal Ahmedabad Meetup Hosted by 300Minds.pdf
PPTX
Galactic Wars XNA Game
DOCX
Y1 gd engine_terminology
PPTX
Introduction to Game Development
PPT
AiRaid: Rise of the Undead
PPTX
mooc course presentation.pptx
DOCX
Y1 gd engine_terminology
DOCX
Y1 gd engine_terminology
PDF
intern.pdf
DOCX
Y1 gd engine_terminology
DOCX
Y1 gd engine_terminology
DOCX
Game engine terminology/glossary
PDF
Kinect v1+Processing workshot fabcafe_taipei
PPTX
Game optimization techniques - Most Commons
PDF
Unity3d scripting tutorial
DOCX
Y1 gd engine_terminology (1) (4)
PPTX
WP7 HUB_XNA overview
DOCX
Engine terminology
Game Development Session - 3 | Introduction to Unity
Android Game Minisyonize
Unreal Ahmedabad Meetup Hosted by 300Minds.pdf
Galactic Wars XNA Game
Y1 gd engine_terminology
Introduction to Game Development
AiRaid: Rise of the Undead
mooc course presentation.pptx
Y1 gd engine_terminology
Y1 gd engine_terminology
intern.pdf
Y1 gd engine_terminology
Y1 gd engine_terminology
Game engine terminology/glossary
Kinect v1+Processing workshot fabcafe_taipei
Game optimization techniques - Most Commons
Unity3d scripting tutorial
Y1 gd engine_terminology (1) (4)
WP7 HUB_XNA overview
Engine terminology

More from Daniela Da Cruz (7)

PDF
Introduction to iOS and Objective-C
PDF
Games Concepts
PDF
C basics
PDF
Interactive Verification of Safety-Critical Systems
PDF
Android Introduction
PDF
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
PDF
Android Introduction - Lesson 1
Introduction to iOS and Objective-C
Games Concepts
C basics
Interactive Verification of Safety-Critical Systems
Android Introduction
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Android Introduction - Lesson 1

Recently uploaded (20)

PDF
Trump Administration's workforce development strategy
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Lesson notes of climatology university.
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Classroom Observation Tools for Teachers
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
RMMM.pdf make it easy to upload and study
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PPTX
master seminar digital applications in india
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
Trump Administration's workforce development strategy
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Chinmaya Tiranga quiz Grand Finale.pdf
Lesson notes of climatology university.
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Classroom Observation Tools for Teachers
Paper A Mock Exam 9_ Attempt review.pdf.
RMMM.pdf make it easy to upload and study
Supply Chain Operations Speaking Notes -ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Complications of Minimal Access Surgery at WLH
Final Presentation General Medicine 03-08-2024.pptx
What if we spent less time fighting change, and more time building what’s rig...
2.FourierTransform-ShortQuestionswithAnswers.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
UNIT III MENTAL HEALTH NURSING ASSESSMENT
master seminar digital applications in india
Orientation - ARALprogram of Deped to the Parents.pptx

Game Development with AndEngine

  • 1. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Game Development with AndEngine GLES2 Daniela da Cruz Computação Móvel Licenciatura em Engenharia de Jogos Digitais Instituto Politécnico do Cávado e do Ave October 28, 2013 Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 2. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Introduction Basic Elements Camera Engine Scene Entity Texture TextureRegion Creating the rst scene with AndEngine Handling Scene touches Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 3. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Introduction AndEngine is a free open source OpenGL Android game engine, developed by Nicolas Gramlich. AndEngine is currently available in two avors: GLES1 and GLES2. GLES2, as you might guess, supports OpenGL ES 2.0. https://github.com/nicolasgramlich http://www.matim-dev.com/ Latest version: Tutorials: Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 4. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Introduction AndEngine Advantages: It has a complete 2-D scene graph, with a very easy-to-use API. It works great with the Android activity lifecycle. It has a number of extensions that can be added as plugins. It has multi-touch support. It's free and open-source. AndEngine Disadvantages: The API is undocumented. Sometimes slower in comparison to other engines. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 5. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Basic Elements To create a scene we need 3 basic elements: Camera Engine Scene Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 6. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Camera Camera Since all is based in a game scene we need to setup a camera: Camera(pX, pY, pWidth, pHeight); pX and pY are the coordinates for the origin of the camera pWidth and pHeight are the dimensions, in pixels, of the camera Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 7. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Engine Engine In the engine we dene which camera will be used on the scene: EngineOptions(pFullscreen, pScreenOrientation, pResolutionPolicy(pWidth, pHeight), pCamera) pFullscreen determines whether the game will be play full screen or not pScreenOrientation, here we can choose between LANDSCAPE and PORTRAIT pResolutionPolicy is the ratio of our Engine (same values as in Camera) pCamera is the camera object Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 8. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Scene Scene The Scene class is the root container for all objects to be drawn on the screen. A Scene has a specic amount of Layers, which themselves can contain a (xed or dynamic) amount of Entities. There are subclasses, like the CameraScene/HUD/MenuScene that are drawing themselves to the same position of the Scene no matter where the camera is positioned to. HUD (heads-up display) usage for example for score (it has to be all the time in the same position, follow camera changes). Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 9. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Entity Entity An Entitiy is an object that can be drawn, like Sprites, Rectangles, Text or Lines. An Entity has a position/rotation/scale/color/etc. Sprite - entity with texture TiledSprite - entity with tiled texture, you may switch between tiles. AnimatedSprite - extension of the TiledSprite, you may animate tiles in specied intervals. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 10. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Texture TextureRegion Texture TextureRegion A Texture is a 'image' in the memory of the graphics chip. A TextureRegion denes a rectangle on the Texture. A TextureRegion is used by Sprites to let the system know what part of the big Texture the Sprite is showing. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 11. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Creating the rst scene with AndEngine The rst le created by the project is an Activity. And the rst thing to do in our project is to change the class that this Activity extends. Instead of extending the Activity class, we want to make it extend a class called SimpleBaseGameActivity. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 12. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Creating the rst scene with AndEngine The SimpleBaseActivity class provides additional callbacks and contains the code to make AndEngine work with the Activity life cycle. Each callback that it provides is used for a specic purpose. As soon as you extend this class, we will have to override three functions. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 13. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Extending SimpleBaseGameActivity onCreateEngineOptions this function is where you create an instance of the engine. Every activity that the game uses will have its own instance of the engine that will run within the activity lifecycle. onCreateResources this is the function where we load all the resources that the activity requires into the the VRAM. onCreateScene this function is called after the above two callbacks are executed. This is where we create the scene for our game and use all the textures that we previously loaded into memory. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 14. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Extending SimpleBaseGameActivity Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 15. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Creating a Sprite When creating a Sprite object, we pass four parameters: xCoordinate: Denes the X-position of the sprite. yCoordinate: Denes the Y-position of the sprite. TextureRegion: Denes what part of the texture the sprite will use to draw itself. VertexBuerObjectManager: Think of a vertex buer as an array holding the coordinates of a texture. These coordinates are passed to the OpenGL ES pipeline and ultimately dene what will be drawn. A VertexBuerObjectManager holds all the vertices of all the textures that need to be drawn on the scene. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 16. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Attaching a Sprite to a Scene To attach a sprite, to a dierent entity, for example to the Scene, we have to simply call attachChild method: anyEntity.attachChild(yourSprite); Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 17. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Handling Scene touches Lets say we want to execute a certain action, every time the player touches the screen. We have to implement IOnSceneTouchListener interface. Add unimplemented method. Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 18. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Handling Scene touches The methods that identify if an event occurred or not are: isActionDown(), isActionMove(), isActionUp(). Now all you have to do is to register this touch listener in a certain scene: scene.setOnSceneTouchListener(this); Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave
  • 19. Introduction Basic Elements Creating the rst scene with AndEngine Handling Scene touches Handling Entity touches The problem of this approach is that it will handle every event that occurs in the whole scene. If we want to handle touch events of specic entities, we will need to implement the method onAreaTouch() (the parameters are the event and its coordinates). Game Development with AndEngine GLES2 Computação MóvelLicenciatura em Engenharia de Jogos DigitaisInstituto Politécnico do Cávado e do Ave