SlideShare a Scribd company logo
LibGDX:	
  Internaliza1on	
  and	
  
Scene	
  2D	
  
Jussi	
  Pohjolainen	
  
Tampere	
  University	
  of	
  Applied	
  Sciences	
  
INTERNALIZATION	
  
Support	
  for	
  Mul1ple	
  Languages	
  
•  Create	
  defaults	
  proper1es	
  file:	
  
– MyBundle.properties
•  Create	
  other	
  language	
  files:	
  
– MyBundle.fi_FI.properties
MyBundle.proper1es	
  
title=My Game
score=You score {0}
MyBundle_fi.proper1es	
  
title=Pelini
score=Pisteesi {0}
In	
  Java	
  
Locale locale = new Locale("fi");
I18NBundle myBundle =
I18NBundle.createBundle(Gdx.files.internal("MyBundle"), locale);
String title = myBundle.get("title");
String score = myBundle.get("score", 50);
Notes	
  
•  If	
  you	
  don't	
  specify	
  locale,	
  default	
  locale	
  is	
  
used	
  
•  Charset	
  is	
  UTF-­‐8	
  (without	
  BOM)	
  
•  See:	
  	
  
– hVps://github.com/libgdx/libgdx/wiki/
Interna1onaliza1on-­‐and-­‐Localiza1on	
  
	
  
SCENE2D	
  
Scene2D?	
  
•  It’s	
  op1onal,	
  you	
  don’t	
  need	
  it.	
  But	
  you	
  may	
  
want	
  to	
  use	
  it.	
  
•  May	
  be	
  useful	
  for	
  "board	
  games"	
  
•  Higher	
  level	
  framework	
  for	
  crea>ng	
  games	
  
•  Provides	
  UI	
  Toolkit	
  also:	
  Scene2d.ui	
  
•  Tutorial	
  
–  https://github.com/libgdx/libgdx/wiki/Scene2d
Concepts	
  
•  Stage	
  
– “Screens”,	
  “Stages”,	
  “Levels”	
  
– Camera	
  watching	
  the	
  stage	
  
– Contains	
  group	
  of	
  actors	
  
•  Actors	
  
– “Sprites”	
  
	
  
	
  
Roughly	
  the	
  Idea	
  in	
  Code	
  
Stage gameStage = new Stage();
// PlayerActor extends Actor { .. }
PlayerActor player = new PlayerActor();
// Let's add the actor to the stage
gameStage.addActor(player);
Possibili1es	
  
•  Event	
  system	
  for	
  actors;	
  when	
  actor	
  is	
  
touched,	
  dragged	
  ..	
  
– Hit	
  detec>on;	
  dragging	
  /	
  touching	
  within	
  the	
  
bounds	
  of	
  actor	
  
•  Ac>on	
  system:	
  rotate,	
  move,	
  scale	
  actors	
  in	
  
parallel	
  
– Also	
  rota1on	
  and	
  scaling	
  of	
  group	
  of	
  actors	
  
Stage	
  
•  Stage	
  implements	
  InputProcessor,	
  so	
  it	
  can	
  
directly	
  input	
  events	
  from	
  keyboard	
  and	
  touch	
  
•  Add	
  to	
  your	
  Applica1onAdapter	
  
–  Gdx.input.setInputProcessor(myStage);
•  Stage	
  distributes	
  input	
  to	
  actors	
  
•  Use	
  setViewport	
  to	
  set	
  the	
  camera	
  
–  myStage.setViewPort(...);	
  
•  Stage	
  has	
  act	
  method,	
  by	
  calling	
  this,	
  every	
  act	
  
method	
  of	
  every	
  actor	
  is	
  called	
  
Actors	
  
•  Actor	
  has	
  an	
  posi1on,	
  rect	
  size,	
  scale,	
  
rota1on…	
  
•  Posi1on	
  is	
  the	
  leb	
  corner	
  of	
  the	
  actor	
  
•  Posi1on	
  is	
  rela1ve	
  to	
  the	
  actor’s	
  parent	
  
•  Actor	
  may	
  have	
  ac>ons	
  
– Change	
  the	
  presenta>on	
  of	
  the	
  actor	
  (move,	
  
resize)	
  
•  Actor	
  can	
  react	
  to	
  events	
  
public class StageGame extends ApplicationAdapter {
// Stage contains hierarcy of actors
private Stage stage;
// We will have player actor in the stage
private BlueBirdActor playerActor;
@Override
public void create () {
// Creating the stage
stage = new Stage();
// Creating the actors
playerActor = new BlueBirdActor();
// add actors to stage
stage.addActor(playerActor);
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Call act on every actor
stage.act(Gdx.graphics.getDeltaTime());
// Call draw on every actor
stage.draw();
}
}
public class BlueBirdActor extends Actor {
private Texture texture;
public BlueBirdActor() {
texture = new Texture(Gdx.files.internal("blue-bird-icon.png"));
}
@Override
public void draw(Batch batch, float alpha) {
batch.draw(texture, getX(), getY());
}
@Override
public void act(float delta) {
super.act(delta);
}
}
Event	
  System	
  
•  Stage	
  will	
  be	
  responsible	
  for	
  gedng	
  user	
  input	
  
–  Gdx.input.setInputProcessor(stage);
•  Stage	
  will	
  fire	
  events	
  to	
  actors	
  
•  Actor	
  may	
  receive	
  events	
  if	
  it	
  has	
  a	
  listener	
  
–  actor.addListener(new InputListener()
{ … } );
•  Actor	
  must	
  specify	
  bounds	
  in	
  order	
  to	
  receive	
  
input	
  events	
  within	
  those	
  bounds!	
  
•  To	
  handle	
  key	
  input,	
  actor	
  has	
  to	
  have	
  keyboard	
  
focus	
  
public class StageGame extends ApplicationAdapter {
// Stage contains hierarcy of actors
private Stage stage;
// We will have player actor in the stage
private BlueBirdActor playerActor;
@Override
public void create () {
// Creating the stage
stage = new Stage();
// Sets the InputProcessor that will receive all touch and key input events.
// It will be called before the ApplicationListener.render() method each frame.
//
// Stage handles the calling the inputlisteners for each actor.
Gdx.input.setInputProcessor(stage);
// Creating the actors
playerActor = new BlueBirdActor();
// add actors to stage
stage.addActor(playerActor);
stage.setKeyboardFocus(playerActor);
}
@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// Call act on every actor
stage.act(Gdx.graphics.getDeltaTime());
// Call draw on every actor
stage.draw();
}
}
public class BlueBirdActor extends Actor {
private boolean up, down, left, right
public BlueBirdActor() {
addListener(new PlayerListener());
}
@Override
public void act(float delta) {
if(up) {
setY(getY() + speed * delta);
}
}
// InputListener implements EventListener, just override the methods you need
// Also ActorGestureListener available: fling, pan, zoom, pinch..
class PlayerListener extends InputListener {
@Override
public boolean keyDown(InputEvent event, int keycode) {
if(keycode == Input.Keys.UP) {
up = true;
}
return true;
}
@Override
public boolean keyUp(InputEvent event, int keycode) {
if(keycode == Input.Keys.UP) {
up = false;
}
return true;
}
}
}
Ac1ons	
  
•  Each	
  actor	
  has	
  a	
  list	
  of	
  ac1ons	
  
•  Updated	
  on	
  every	
  frame	
  (act-­‐method)	
  
•  Many	
  ac1ons	
  available	
  
–  MoveToAction
–  RotateToAction
–  ScaleToAction
•  Example	
  
–  MoveToAction action = new MoveToAction();
–  action.setPosition(300f, 700f);
–  action.setDuration(2f);
–  actor.addAction(action);
Grouping	
  Ac1ons	
  in	
  Sequence	
  
SequenceAction sequenceAction = new SequenceAction();
MoveToAction moveAction = new MoveToAction();
RotateToAction rotateAction = new RotateToAction();
ScaleToAction scaleAction = new ScaleToAction();
moveAction.setPosition(200f, 400f);
moveAction.setDuration(1f);
rotateAction.setRotation(rotate);
rotateAction.setDuration(1f);
scaleAction.setScale(0.5f);
scaleAction.setDuration(1f);
sequenceAction.addAction(moveAction);
sequenceAction.addAction(rotateAction);
sequenceAction.addAction(scaleAction);
actor.addAction(sequenceAction);
Grouping	
  Ac1ons	
  in	
  Parallel	
  
ParallelAction parallel = new ParallelAction ();
MoveToAction moveAction = new MoveToAction();
RotateToAction rotateAction = new RotateToAction();
ScaleToAction scaleAction = new ScaleToAction();
moveAction.setPosition(200f, 400f);
moveAction.setDuration(1f);
rotateAction.setRotation(rotate);
rotateAction.setDuration(1f);
scaleAction.setScale(0.5f);
scaleAction.setDuration(1f);
parallel.addAction(moveAction);
parallel.addAction(rotateAction);
parallel.addAction(scaleAction);
actor.addAction(parallel);
Ac1ons	
  Complete?	
  
SequenceAction sequenceAction = new SequenceAction();
ParallelAction parallelAction = new ParallelAction();
MoveToAction moveAction = new MoveToAction();
RotateToAction rotateAction = new RotateToAction();
RunnableAction runnableAction = new RunnableAction();
moveAction.setPosition(200f, 400f);
moveAction.setDuration(1f);
moveAction.setInterpolation(Interpolation.bounceOut);
rotateAction.setRotation(rotate);
rotateAction.setDuration(1f);
runnableAction.setRunnable(new Runnable() {
public void run() {
System.out.println("done!");
}
});
parallelAction.addAction(rotateAction);
parallelAction.addAction(moveAction);
sequenceAction.addAction(parallelAction);
sequenceAction.addAction(runnableAction);
Enable	
  rotate	
  and	
  scale	
  in	
  drawing	
  
@Override
public void draw(Batch batch, float alpha){
batch.draw(texture,
this.getX(), this.getY(),
this.getOriginX(),
this.getOriginY(),
this.getWidth(),
this.getHeight(),
this.getScaleX(),
this.getScaleY(),
this.getRotation(),0,0,
texture.getWidth(), texture.getHeight(), false, false);
}
Grouping	
  
Group group = new Group();
group.addActor(playerActor);
group.addActor(monsterActor);
group.addAction( ... );
stage.addActor(group);
CREATING	
  UI:	
  SCENE2D.UI	
  
	
  
Scene2D.UI	
  
•  Tutorial	
  
– hVps://github.com/libgdx/libgdx/wiki/Scene2d.ui	
  
•  To	
  quickly	
  get	
  started,	
  add	
  following	
  to	
  your	
  
project	
  
– uiskin.png,	
  uiskin.atlas,	
  uiskin.json,	
  default.fnt	
  
– hVps://github.com/libgdx/libgdx/tree/master/
tests/gdx-­‐tests-­‐android/assets/data	
  
•  Tutorial	
  and	
  examples	
  
– hVps://github.com/libgdx/libgdx/wiki/Scene2d.ui	
  
TextBuVon	
  example	
  
Skin skin = new Skin( Gdx.files.internal("uiskin.json") );
final TextButton button = new TextButton("Hello", skin);
button.setWidth(200f);
button.setHeight(20f);
button.setPosition(Gdx.graphics.getWidth() /2 - 100f, Gdx.graphics.getHeight()/2
- 10f);
startStage.addActor(button);
Gdx.input.setInputProcessor(startStage);
button.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
whichScreen = !whichScreen;
Gdx.input.setInputProcessor(gameStage);
}
});

More Related Content

What's hot

Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Unity Technologies
 
Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019
Unity Technologies
 
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
Unity Technologies
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019
Unity Technologies
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
Alfonso Torres
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial Mapping
Takashi Yoshinaga
 
Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲
吳錫修 (ShyiShiou Wu)
 
Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014
Vincenzo Favara
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platformJussi Pohjolainen
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
Unity Technologies
 
Game Development using SDL and the PDK
Game Development using SDL and the PDK Game Development using SDL and the PDK
Game Development using SDL and the PDK
ardiri
 
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate ReptiliansUsing Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
Nilhcem
 
Game Development with SDL and Perl
Game Development with SDL and PerlGame Development with SDL and Perl
Game Development with SDL and Perl
garux
 
Android dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWorkAndroid dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWork
DroidConTLV
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game Engines
Bryan Duggan
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
gamifi.cc
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
Hussain Behestee
 
Code Pad
Code PadCode Pad
Code Pad
Chris Parnin
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
Eric Basile
 

What's hot (20)

Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
 
Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019Converting Scene Data to DOTS – Unite Copenhagen 2019
Converting Scene Data to DOTS – Unite Copenhagen 2019
 
Soc research
Soc researchSoc research
Soc research
 
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
Unity asset workflows for Film and Animation pipelines - Unite Copenhagen 2019
 
Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019Custom SRP and graphics workflows - Unite Copenhagen 2019
Custom SRP and graphics workflows - Unite Copenhagen 2019
 
Sequence diagrams
Sequence diagramsSequence diagrams
Sequence diagrams
 
HoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial MappingHoloLens Programming Tutorial: AirTap & Spatial Mapping
HoloLens Programming Tutorial: AirTap & Spatial Mapping
 
Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲Unity遊戲程式設計 - 2D Platformer遊戲
Unity遊戲程式設計 - 2D Platformer遊戲
 
Unity3 d devfest-2014
Unity3 d devfest-2014Unity3 d devfest-2014
Unity3 d devfest-2014
 
Creating Games for Asha - platform
Creating Games for Asha - platformCreating Games for Asha - platform
Creating Games for Asha - platform
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
 
Game Development using SDL and the PDK
Game Development using SDL and the PDK Game Development using SDL and the PDK
Game Development using SDL and the PDK
 
Using Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate ReptiliansUsing Android Things to Detect & Exterminate Reptilians
Using Android Things to Detect & Exterminate Reptilians
 
Game Development with SDL and Perl
Game Development with SDL and PerlGame Development with SDL and Perl
Game Development with SDL and Perl
 
Android dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWorkAndroid dev toolbox - Shem Magnezi, WeWork
Android dev toolbox - Shem Magnezi, WeWork
 
Scene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game EnginesScene Graphs & Component Based Game Engines
Scene Graphs & Component Based Game Engines
 
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
Developing applications and games in Unity engine - Matej Jariabka, Rudolf Ka...
 
iOS Training Session-3
iOS Training Session-3iOS Training Session-3
iOS Training Session-3
 
Code Pad
Code PadCode Pad
Code Pad
 
SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013SDL2 Game Development VT Code Camp 2013
SDL2 Game Development VT Code Camp 2013
 

Viewers also liked

Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
Jussi Pohjolainen
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
Jussi Pohjolainen
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
Jussi Pohjolainen
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
Jussi Pohjolainen
 
Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
Jussi Pohjolainen
 
iOS Selectors Blocks and Delegation
iOS Selectors Blocks and DelegationiOS Selectors Blocks and Delegation
iOS Selectors Blocks and DelegationJussi Pohjolainen
 
Building games-with-libgdx
Building games-with-libgdxBuilding games-with-libgdx
Building games-with-libgdx
Jumping Bean
 
LibGDX: Cross Platform Game Development
LibGDX: Cross Platform Game DevelopmentLibGDX: Cross Platform Game Development
LibGDX: Cross Platform Game Development
Intel® Software
 

Viewers also liked (9)

Building Android games using LibGDX
Building Android games using LibGDXBuilding Android games using LibGDX
Building Android games using LibGDX
 
Intro to Building Android Games using libGDX
Intro to Building Android Games using libGDXIntro to Building Android Games using libGDX
Intro to Building Android Games using libGDX
 
libGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and PreferenceslibGDX: Screens, Fonts and Preferences
libGDX: Screens, Fonts and Preferences
 
Java Web Services
Java Web ServicesJava Web Services
Java Web Services
 
Moved to Speakerdeck
Moved to SpeakerdeckMoved to Speakerdeck
Moved to Speakerdeck
 
iOS Selectors Blocks and Delegation
iOS Selectors Blocks and DelegationiOS Selectors Blocks and Delegation
iOS Selectors Blocks and Delegation
 
Lib gdx 2015_corkdevio
Lib gdx 2015_corkdevioLib gdx 2015_corkdevio
Lib gdx 2015_corkdevio
 
Building games-with-libgdx
Building games-with-libgdxBuilding games-with-libgdx
Building games-with-libgdx
 
LibGDX: Cross Platform Game Development
LibGDX: Cross Platform Game DevelopmentLibGDX: Cross Platform Game Development
LibGDX: Cross Platform Game Development
 

Similar to libGDX: Scene2D

Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
Nick Pruehs
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platform
goodfriday
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
C4Media
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
Scott Wlaschin
 
AIWolf programming guide
AIWolf programming guideAIWolf programming guide
AIWolf programming guide
Hirotaka Osawa
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEE
Hendrik Ebel
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockRobot Media
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
James Williams
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
isenbergwarne4100
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
Fernando Daciuk
 
Unity 3D Runtime Animation Generation
Unity 3D Runtime Animation GenerationUnity 3D Runtime Animation Generation
Unity 3D Runtime Animation Generation
Dustin Graham
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
Hua Chu
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and Tutorial
Tsukasa Sugiura
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
DroidConTLV
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
Miguel Angel Horna
 
a million bots can't be wrong
a million bots can't be wronga million bots can't be wrong
a million bots can't be wrong
Vasil Remeniuk
 
Василий Ременюк «Курс молодого подрывника»
Василий Ременюк «Курс молодого подрывника» Василий Ременюк «Курс молодого подрывника»
Василий Ременюк «Курс молодого подрывника»
e-Legion
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
Sencha
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
Robot Media
 
watchOS 2でゲーム作ってみた話
watchOS 2でゲーム作ってみた話watchOS 2でゲーム作ってみた話
watchOS 2でゲーム作ってみた話
Kohki Miki
 

Similar to libGDX: Scene2D (20)

Unreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal EditorUnreal Engine Basics 02 - Unreal Editor
Unreal Engine Basics 02 - Unreal Editor
 
Silverlight as a Gaming Platform
Silverlight as a Gaming PlatformSilverlight as a Gaming Platform
Silverlight as a Gaming Platform
 
Asynchronous Programming at Netflix
Asynchronous Programming at NetflixAsynchronous Programming at Netflix
Asynchronous Programming at Netflix
 
Enterprise Tic-Tac-Toe
Enterprise Tic-Tac-ToeEnterprise Tic-Tac-Toe
Enterprise Tic-Tac-Toe
 
AIWolf programming guide
AIWolf programming guideAIWolf programming guide
AIWolf programming guide
 
iOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEEiOS Einführung am Beispiel von play NEXT TEE
iOS Einführung am Beispiel von play NEXT TEE
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
Game programming with Groovy
Game programming with GroovyGame programming with Groovy
Game programming with Groovy
 
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdfpublic void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
public void turnRight(double degrees) {rotationInDegrees + - = deg.pdf
 
WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015WordPress Realtime - WordCamp São Paulo 2015
WordPress Realtime - WordCamp São Paulo 2015
 
Unity 3D Runtime Animation Generation
Unity 3D Runtime Animation GenerationUnity 3D Runtime Animation Generation
Unity 3D Runtime Animation Generation
 
Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python Taipei.py 2018 - Control device via ioctl from Python
Taipei.py 2018 - Control device via ioctl from Python
 
Kinect v2 Introduction and Tutorial
Kinect v2 Introduction and TutorialKinect v2 Introduction and Tutorial
Kinect v2 Introduction and Tutorial
 
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
Tricks to Making a Realtime SurfaceView Actually Perform in Realtime - Maarte...
 
The Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation PlatformsThe Challenge of Bringing FEZ to PlayStation Platforms
The Challenge of Bringing FEZ to PlayStation Platforms
 
a million bots can't be wrong
a million bots can't be wronga million bots can't be wrong
a million bots can't be wrong
 
Василий Ременюк «Курс молодого подрывника»
Василий Ременюк «Курс молодого подрывника» Василий Ременюк «Курс молодого подрывника»
Василий Ременюк «Курс молодого подрывника»
 
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
SenchaCon 2016: Building a Faceted Catalog of Video Game Assets Using Ext JS ...
 
Unit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon GaliciaUnit testing en iOS @ MobileCon Galicia
Unit testing en iOS @ MobileCon Galicia
 
watchOS 2でゲーム作ってみた話
watchOS 2でゲーム作ってみた話watchOS 2でゲーム作ってみた話
watchOS 2でゲーム作ってみた話
 

More from Jussi Pohjolainen

Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript DevelopmentJussi Pohjolainen
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
Jussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
Jussi Pohjolainen
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesJussi Pohjolainen
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformJussi Pohjolainen
 
Quick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileJussi Pohjolainen
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet LanguageJussi Pohjolainen
 

More from Jussi Pohjolainen (19)

Advanced JavaScript Development
Advanced JavaScript DevelopmentAdvanced JavaScript Development
Advanced JavaScript Development
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Introduction to AngularJS
Introduction to AngularJSIntroduction to AngularJS
Introduction to AngularJS
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and GesturesCreating Asha Games: Game Pausing, Orientation, Sensors and Gestures
Creating Asha Games: Game Pausing, Orientation, Sensors and Gestures
 
Intro to Asha UI
Intro to Asha UIIntro to Asha UI
Intro to Asha UI
 
Intro to Java ME and Asha Platform
Intro to Java ME and Asha PlatformIntro to Java ME and Asha Platform
Intro to Java ME and Asha Platform
 
Intro to PhoneGap
Intro to PhoneGapIntro to PhoneGap
Intro to PhoneGap
 
Quick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery MobileQuick Intro to JQuery and JQuery Mobile
Quick Intro to JQuery and JQuery Mobile
 
JavaScript Inheritance
JavaScript InheritanceJavaScript Inheritance
JavaScript Inheritance
 
JS OO and Closures
JS OO and ClosuresJS OO and Closures
JS OO and Closures
 
Short intro to ECMAScript
Short intro to ECMAScriptShort intro to ECMAScript
Short intro to ECMAScript
 
XAMPP
XAMPPXAMPP
XAMPP
 
Building Web Services
Building Web ServicesBuilding Web Services
Building Web Services
 
CSS
CSSCSS
CSS
 
Extensible Stylesheet Language
Extensible Stylesheet LanguageExtensible Stylesheet Language
Extensible Stylesheet Language
 
About Http Connection
About Http ConnectionAbout Http Connection
About Http Connection
 

Recently uploaded

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
Dorra BARTAGUIZ
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
Elevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object CalisthenicsElevating Tactical DDD Patterns Through Object Calisthenics
Elevating Tactical DDD Patterns Through Object Calisthenics
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

libGDX: Scene2D

  • 1. LibGDX:  Internaliza1on  and   Scene  2D   Jussi  Pohjolainen   Tampere  University  of  Applied  Sciences  
  • 3. Support  for  Mul1ple  Languages   •  Create  defaults  proper1es  file:   – MyBundle.properties •  Create  other  language  files:   – MyBundle.fi_FI.properties
  • 6. In  Java   Locale locale = new Locale("fi"); I18NBundle myBundle = I18NBundle.createBundle(Gdx.files.internal("MyBundle"), locale); String title = myBundle.get("title"); String score = myBundle.get("score", 50);
  • 7. Notes   •  If  you  don't  specify  locale,  default  locale  is   used   •  Charset  is  UTF-­‐8  (without  BOM)   •  See:     – hVps://github.com/libgdx/libgdx/wiki/ Interna1onaliza1on-­‐and-­‐Localiza1on    
  • 9. Scene2D?   •  It’s  op1onal,  you  don’t  need  it.  But  you  may   want  to  use  it.   •  May  be  useful  for  "board  games"   •  Higher  level  framework  for  crea>ng  games   •  Provides  UI  Toolkit  also:  Scene2d.ui   •  Tutorial   –  https://github.com/libgdx/libgdx/wiki/Scene2d
  • 10. Concepts   •  Stage   – “Screens”,  “Stages”,  “Levels”   – Camera  watching  the  stage   – Contains  group  of  actors   •  Actors   – “Sprites”      
  • 11. Roughly  the  Idea  in  Code   Stage gameStage = new Stage(); // PlayerActor extends Actor { .. } PlayerActor player = new PlayerActor(); // Let's add the actor to the stage gameStage.addActor(player);
  • 12. Possibili1es   •  Event  system  for  actors;  when  actor  is   touched,  dragged  ..   – Hit  detec>on;  dragging  /  touching  within  the   bounds  of  actor   •  Ac>on  system:  rotate,  move,  scale  actors  in   parallel   – Also  rota1on  and  scaling  of  group  of  actors  
  • 13. Stage   •  Stage  implements  InputProcessor,  so  it  can   directly  input  events  from  keyboard  and  touch   •  Add  to  your  Applica1onAdapter   –  Gdx.input.setInputProcessor(myStage); •  Stage  distributes  input  to  actors   •  Use  setViewport  to  set  the  camera   –  myStage.setViewPort(...);   •  Stage  has  act  method,  by  calling  this,  every  act   method  of  every  actor  is  called  
  • 14. Actors   •  Actor  has  an  posi1on,  rect  size,  scale,   rota1on…   •  Posi1on  is  the  leb  corner  of  the  actor   •  Posi1on  is  rela1ve  to  the  actor’s  parent   •  Actor  may  have  ac>ons   – Change  the  presenta>on  of  the  actor  (move,   resize)   •  Actor  can  react  to  events  
  • 15. public class StageGame extends ApplicationAdapter { // Stage contains hierarcy of actors private Stage stage; // We will have player actor in the stage private BlueBirdActor playerActor; @Override public void create () { // Creating the stage stage = new Stage(); // Creating the actors playerActor = new BlueBirdActor(); // add actors to stage stage.addActor(playerActor); } @Override public void render () { Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Call act on every actor stage.act(Gdx.graphics.getDeltaTime()); // Call draw on every actor stage.draw(); } }
  • 16. public class BlueBirdActor extends Actor { private Texture texture; public BlueBirdActor() { texture = new Texture(Gdx.files.internal("blue-bird-icon.png")); } @Override public void draw(Batch batch, float alpha) { batch.draw(texture, getX(), getY()); } @Override public void act(float delta) { super.act(delta); } }
  • 17. Event  System   •  Stage  will  be  responsible  for  gedng  user  input   –  Gdx.input.setInputProcessor(stage); •  Stage  will  fire  events  to  actors   •  Actor  may  receive  events  if  it  has  a  listener   –  actor.addListener(new InputListener() { … } ); •  Actor  must  specify  bounds  in  order  to  receive   input  events  within  those  bounds!   •  To  handle  key  input,  actor  has  to  have  keyboard   focus  
  • 18. public class StageGame extends ApplicationAdapter { // Stage contains hierarcy of actors private Stage stage; // We will have player actor in the stage private BlueBirdActor playerActor; @Override public void create () { // Creating the stage stage = new Stage(); // Sets the InputProcessor that will receive all touch and key input events. // It will be called before the ApplicationListener.render() method each frame. // // Stage handles the calling the inputlisteners for each actor. Gdx.input.setInputProcessor(stage); // Creating the actors playerActor = new BlueBirdActor(); // add actors to stage stage.addActor(playerActor); stage.setKeyboardFocus(playerActor); } @Override public void render () { Gdx.gl.glClearColor(1, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // Call act on every actor stage.act(Gdx.graphics.getDeltaTime()); // Call draw on every actor stage.draw(); } }
  • 19. public class BlueBirdActor extends Actor { private boolean up, down, left, right public BlueBirdActor() { addListener(new PlayerListener()); } @Override public void act(float delta) { if(up) { setY(getY() + speed * delta); } } // InputListener implements EventListener, just override the methods you need // Also ActorGestureListener available: fling, pan, zoom, pinch.. class PlayerListener extends InputListener { @Override public boolean keyDown(InputEvent event, int keycode) { if(keycode == Input.Keys.UP) { up = true; } return true; } @Override public boolean keyUp(InputEvent event, int keycode) { if(keycode == Input.Keys.UP) { up = false; } return true; } } }
  • 20. Ac1ons   •  Each  actor  has  a  list  of  ac1ons   •  Updated  on  every  frame  (act-­‐method)   •  Many  ac1ons  available   –  MoveToAction –  RotateToAction –  ScaleToAction •  Example   –  MoveToAction action = new MoveToAction(); –  action.setPosition(300f, 700f); –  action.setDuration(2f); –  actor.addAction(action);
  • 21. Grouping  Ac1ons  in  Sequence   SequenceAction sequenceAction = new SequenceAction(); MoveToAction moveAction = new MoveToAction(); RotateToAction rotateAction = new RotateToAction(); ScaleToAction scaleAction = new ScaleToAction(); moveAction.setPosition(200f, 400f); moveAction.setDuration(1f); rotateAction.setRotation(rotate); rotateAction.setDuration(1f); scaleAction.setScale(0.5f); scaleAction.setDuration(1f); sequenceAction.addAction(moveAction); sequenceAction.addAction(rotateAction); sequenceAction.addAction(scaleAction); actor.addAction(sequenceAction);
  • 22. Grouping  Ac1ons  in  Parallel   ParallelAction parallel = new ParallelAction (); MoveToAction moveAction = new MoveToAction(); RotateToAction rotateAction = new RotateToAction(); ScaleToAction scaleAction = new ScaleToAction(); moveAction.setPosition(200f, 400f); moveAction.setDuration(1f); rotateAction.setRotation(rotate); rotateAction.setDuration(1f); scaleAction.setScale(0.5f); scaleAction.setDuration(1f); parallel.addAction(moveAction); parallel.addAction(rotateAction); parallel.addAction(scaleAction); actor.addAction(parallel);
  • 23. Ac1ons  Complete?   SequenceAction sequenceAction = new SequenceAction(); ParallelAction parallelAction = new ParallelAction(); MoveToAction moveAction = new MoveToAction(); RotateToAction rotateAction = new RotateToAction(); RunnableAction runnableAction = new RunnableAction(); moveAction.setPosition(200f, 400f); moveAction.setDuration(1f); moveAction.setInterpolation(Interpolation.bounceOut); rotateAction.setRotation(rotate); rotateAction.setDuration(1f); runnableAction.setRunnable(new Runnable() { public void run() { System.out.println("done!"); } }); parallelAction.addAction(rotateAction); parallelAction.addAction(moveAction); sequenceAction.addAction(parallelAction); sequenceAction.addAction(runnableAction);
  • 24. Enable  rotate  and  scale  in  drawing   @Override public void draw(Batch batch, float alpha){ batch.draw(texture, this.getX(), this.getY(), this.getOriginX(), this.getOriginY(), this.getWidth(), this.getHeight(), this.getScaleX(), this.getScaleY(), this.getRotation(),0,0, texture.getWidth(), texture.getHeight(), false, false); }
  • 25. Grouping   Group group = new Group(); group.addActor(playerActor); group.addActor(monsterActor); group.addAction( ... ); stage.addActor(group);
  • 27. Scene2D.UI   •  Tutorial   – hVps://github.com/libgdx/libgdx/wiki/Scene2d.ui   •  To  quickly  get  started,  add  following  to  your   project   – uiskin.png,  uiskin.atlas,  uiskin.json,  default.fnt   – hVps://github.com/libgdx/libgdx/tree/master/ tests/gdx-­‐tests-­‐android/assets/data   •  Tutorial  and  examples   – hVps://github.com/libgdx/libgdx/wiki/Scene2d.ui  
  • 28. TextBuVon  example   Skin skin = new Skin( Gdx.files.internal("uiskin.json") ); final TextButton button = new TextButton("Hello", skin); button.setWidth(200f); button.setHeight(20f); button.setPosition(Gdx.graphics.getWidth() /2 - 100f, Gdx.graphics.getHeight()/2 - 10f); startStage.addActor(button); Gdx.input.setInputProcessor(startStage); button.addListener(new ClickListener(){ @Override public void clicked(InputEvent event, float x, float y){ whichScreen = !whichScreen; Gdx.input.setInputProcessor(gameStage); } });