SlideShare uma empresa Scribd logo
1 de 19
Baixar para ler offline
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

Mais conteúdo relacionado

Mais procurados

Forest assassin 2 d platformer game
Forest assassin 2 d platformer gameForest assassin 2 d platformer game
Forest assassin 2 d platformer gameAnshuman Pattnaik
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)noorcon
 
The Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineThe Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineOrisysIndia
 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game EngineMohsen Mirhoseini
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with UnityPetri Lankoski
 
Unity Programming
Unity Programming Unity Programming
Unity Programming Sperasoft
 
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84Mahmoud Samir Fayed
 
Unity 3D game engine seminar
Unity 3D game engine  seminarUnity 3D game engine  seminar
Unity 3D game engine seminarNikhilThorat15
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflowcrisgalliano
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity IntroductionJuwal Bose
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202Mahmoud Samir Fayed
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unitydavidluzgouveia
 
Academy PRO: Unity 3D. Scripting
Academy PRO: Unity 3D. ScriptingAcademy PRO: Unity 3D. Scripting
Academy PRO: Unity 3D. ScriptingBinary Studio
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)noorcon
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)noorcon
 
Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine OverviewSharad Mitra
 

Mais procurados (20)

Forest assassin 2 d platformer game
Forest assassin 2 d platformer gameForest assassin 2 d platformer game
Forest assassin 2 d platformer game
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 3 (Preview)
 
The Basics of Unity - The Game Engine
The Basics of Unity - The Game EngineThe Basics of Unity - The Game Engine
The Basics of Unity - The Game Engine
 
Introduction to Unity3D Game Engine
Introduction to Unity3D Game EngineIntroduction to Unity3D Game Engine
Introduction to Unity3D Game Engine
 
Unity 3D, A game engine
Unity 3D, A game engineUnity 3D, A game engine
Unity 3D, A game engine
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
 
WP7 HUB_XNA
WP7 HUB_XNAWP7 HUB_XNA
WP7 HUB_XNA
 
GameMaker Workflow
GameMaker WorkflowGameMaker Workflow
GameMaker Workflow
 
Unity Programming
Unity Programming Unity Programming
Unity Programming
 
The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84The Ring programming language version 1.2 book - Part 36 of 84
The Ring programming language version 1.2 book - Part 36 of 84
 
Unity 3D game engine seminar
Unity 3D game engine  seminarUnity 3D game engine  seminar
Unity 3D game engine seminar
 
Y1 gd level_designworkflow
Y1 gd level_designworkflowY1 gd level_designworkflow
Y1 gd level_designworkflow
 
Unity 3d
Unity 3dUnity 3d
Unity 3d
 
Unity Introduction
Unity IntroductionUnity Introduction
Unity Introduction
 
The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202The Ring programming language version 1.8 book - Part 55 of 202
The Ring programming language version 1.8 book - Part 55 of 202
 
Game Development with Unity
Game Development with UnityGame Development with Unity
Game Development with Unity
 
Academy PRO: Unity 3D. Scripting
Academy PRO: Unity 3D. ScriptingAcademy PRO: Unity 3D. Scripting
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 2 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 2 (Preview)
 
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
Introduction to Game Programming: Using C# and Unity 3D - Chapter 6 (Preview)
 
Game Engine Overview
Game Engine OverviewGame Engine Overview
Game Engine Overview
 

Destaque

Programming android game using and engine
Programming android game using and engineProgramming android game using and engine
Programming android game using and engineNGUYEN VAN LUONG
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAhsanul Karim
 
Intent in android
Intent in androidIntent in android
Intent in androidDurai S
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversCodeAndroid
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - IntentDaniela Da Cruz
 

Destaque (7)

Android Lesson 2
Android Lesson 2Android Lesson 2
Android Lesson 2
 
Programming android game using and engine
Programming android game using and engineProgramming android game using and engine
Programming android game using and engine
 
Android Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver TutorialAndroid Application Component: BroadcastReceiver Tutorial
Android Application Component: BroadcastReceiver Tutorial
 
Intent in android
Intent in androidIntent in android
Intent in android
 
Android intents
Android intentsAndroid intents
Android intents
 
Android: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast ReceiversAndroid: Intent, Intent Filter, Broadcast Receivers
Android: Intent, Intent Filter, Broadcast Receivers
 
Android Lesson 3 - Intent
Android Lesson 3 - IntentAndroid Lesson 3 - Intent
Android Lesson 3 - Intent
 

Semelhante a AndEngine Game Dev Guide

Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to UnityKoderunners
 
Android Game Minisyonize
Android Game MinisyonizeAndroid Game Minisyonize
Android Game Minisyonizesavvy
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA GameSohil Gupta
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminologyLuke Summers
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game DevelopmentShaan Alam
 
AiRaid: Rise of the Undead
AiRaid: Rise of the UndeadAiRaid: Rise of the Undead
AiRaid: Rise of the Undead3scale.net
 
mooc course presentation.pptx
mooc course presentation.pptxmooc course presentation.pptx
mooc course presentation.pptxAkshaySingh657739
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminologyJordanianmc
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminologyJaket123
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminologyJordanianmc
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossarygordonpj96
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiMao Wu
 
Game optimization techniques - Most Commons
Game optimization techniques - Most CommonsGame optimization techniques - Most Commons
Game optimization techniques - Most Commonsniraj vishwakarma
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorialhungnttg
 
Y1 gd engine_terminology (1) (4)
Y1 gd engine_terminology (1) (4) Y1 gd engine_terminology (1) (4)
Y1 gd engine_terminology (1) (4) TomCrook
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overviewMICTT Palma
 

Semelhante a AndEngine Game Dev Guide (20)

Game Development Session - 3 | Introduction to Unity
Game Development Session - 3 | Introduction to  UnityGame Development Session - 3 | Introduction to  Unity
Game Development Session - 3 | Introduction to Unity
 
Android Game Minisyonize
Android Game MinisyonizeAndroid Game Minisyonize
Android Game Minisyonize
 
Galactic Wars XNA Game
Galactic Wars XNA GameGalactic Wars XNA Game
Galactic Wars XNA Game
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
Introduction to Game Development
Introduction to Game DevelopmentIntroduction to Game Development
Introduction to Game Development
 
AiRaid: Rise of the Undead
AiRaid: Rise of the UndeadAiRaid: Rise of the Undead
AiRaid: Rise of the Undead
 
mooc course presentation.pptx
mooc course presentation.pptxmooc course presentation.pptx
mooc course presentation.pptx
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
intern.pdf
intern.pdfintern.pdf
intern.pdf
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
Y1 gd engine_terminology
Y1 gd engine_terminologyY1 gd engine_terminology
Y1 gd engine_terminology
 
Game engine terminology/glossary
Game engine terminology/glossaryGame engine terminology/glossary
Game engine terminology/glossary
 
Kinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipeiKinect v1+Processing workshot fabcafe_taipei
Kinect v1+Processing workshot fabcafe_taipei
 
Game optimization techniques - Most Commons
Game optimization techniques - Most CommonsGame optimization techniques - Most Commons
Game optimization techniques - Most Commons
 
Unity3d scripting tutorial
Unity3d scripting tutorialUnity3d scripting tutorial
Unity3d scripting tutorial
 
Y1 gd engine_terminology (1) (4)
Y1 gd engine_terminology (1) (4) Y1 gd engine_terminology (1) (4)
Y1 gd engine_terminology (1) (4)
 
WP7 HUB_XNA overview
WP7 HUB_XNA overviewWP7 HUB_XNA overview
WP7 HUB_XNA overview
 
Engine terminology
Engine terminologyEngine terminology
Engine terminology
 
Alexey Savchenko, Unreal Engine
Alexey Savchenko, Unreal EngineAlexey Savchenko, Unreal Engine
Alexey Savchenko, Unreal Engine
 

Mais de Daniela Da Cruz

Introduction to iOS and Objective-C
Introduction to iOS and Objective-CIntroduction to iOS and Objective-C
Introduction to iOS and Objective-CDaniela Da Cruz
 
Interactive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsInteractive Verification of Safety-Critical Systems
Interactive Verification of Safety-Critical SystemsDaniela Da Cruz
 
Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Comment Analysis approach for Program Comprehension (Software Engineering Wor...
Comment Analysis approach for Program Comprehension (Software Engineering Wor...Daniela Da Cruz
 
Android Introduction - Lesson 1
Android Introduction - Lesson 1Android Introduction - Lesson 1
Android Introduction - Lesson 1Daniela Da Cruz
 

Mais de Daniela Da Cruz (7)

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

Último

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 

Último (20)

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 

AndEngine Game Dev Guide

  • 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