Anuncio

lunes, 14 de abril de 2014

Using Screen and Game Classes

There is some confusion about the Game and Screen classes. Part of that may be because the Project Setup tutorial in the official libgdx wiki has you creating a Game class, which is also different than the com.badlogic.gdx.Game class.

Details

When you start developing a libgdx app, you will set up your project to where the Android starter (AndroidApplication class) and/or Desktop starter (LwjglApplication or JoglApplication) projects initialize an ApplicationListener. The ApplicationListener's methods can be managed by using Game and Screen.

com.badlogic.gdx.Game

We create a class that extends Game, which implements ApplicationListener. It will be used as the "Main" libgdx class, the starting point basically, in the core libgdx project. Your create() method is here, and once create() is done it moves on to rendering screens, (the current screen, that is). To switch the current screen, all you need to do is call game.setScreen(screen);

com.badlogic.gdx.Screen

We create our own classes that implement the Screen interface, and use them kind of like mini ApplicationListeners. They have render(), pause(), resume(), and resize(), all called when the ApplicationListener's respective methods would normally be called. They also have other methods- hide() and show().

When setScreen(screen) is called, the current screen's hide() method is called, the new screen becomes the current screen, and its show() method is called. Then the new screen's render() method is called each frame by Game. Only one screen is rendered at a time.

Note that Screen's dispose() method is never called automatically- when ApplicationListener's dispose() method is called, Game calls screen.hide() instead.

Tips

I prefer to keep a single instance of each screen around for the life of the game, so that new Screen objects are not being created every screen change, to avoid garbage collection.

Each Screen should have a reference to your Game, if for no other reason than to switch screens from within a screen.

Game code example

 import com.badlogic.gdx.Game;

public class MyGame extends Game {


        MainMenuScreen mainMenuScreen;
        AnotherScreen anotherScreen;


       @Override
        public void create() {
                mainMenuScreen = new MainMenuScreen(this);
                anotherScreen = new AnotherScreen(this);
                setScreen(mainMenuScreen);              
        }
 }

Screen code example

 import com.badlogic.gdx.Screen;

public class MainMenuScreen implements Screen {


       MyGame game; // Note it's "MyGame" not "Game"


       // constructor to keep a reference to the main Game class
        public MainMenuScreen(MyGame game){
                this.game = game;
        }
        
        @Override
        public void render(float delta) {
                // update and draw stuff
             if (Gdx.input.justTouched()) // use your own criterion here
                 game.setScreen(game.anotherScreen);
        }


       @Override
        public void resize(int width, int height) {
        }


       @Override
        public void show() {
             // called when this screen is set as the screen with game.setScreen();
        }


       @Override
        public void hide() {
             // called when current screen changes from this to a different screen
        }


       @Override
        public void pause() {
        }


       @Override
        public void resume() {
        }


       @Override
        public void dispose() {
                // never called automatically
        }
 }

FUENTE: https://code.google.com/p/libgdx-users/wiki/ScreenAndGameClasses


sábado, 12 de abril de 2014

75 Essential Cheat Sheets for Designers and Programmers

Programming is not an easy job, and requires a lot of concentration and expert reference. You might get struck anytime, anywhere in the code, where you can’t work out the things, but need to finish the code as soon as possible, for your boss sitting hot over your head. At that moment of time, you wish, that something existed that could give you a quick help, or a quick reference, solving your problem in moments, and you get the things to work, as they are supposed to be!  The good news, there exists a tool like this. Not actually a tool, we call them Cheat Sheets.
Cheat sheets are a collection of notes and facts used for quick reference. These are same, like those of the cheat slips, the students used to take during their exams. They had to use the cheat sheet without the instructor’s knowledge, but in the case of programming, you are allowed to use cheat sheets during your coding jobs!
Giving a rough idea, about what a cheat sheet includes, is that it contains the information about all the syntaxes and data properties, that are used in that particular coding language. May it be C, HTML, JAVA,LISP, Haskell, PHP, Python, Ruby, Photoshop, etc you can find cheat sheets for all of the languages easily over the web! These are great tools, and will help you greatly in your programming process, and will ease your job to a great extent!
Here, we have a list of the best 75 cheat sheets for the designers and developers. We call them the best ones, for the fact, these are up to the mark, contain to the point information, and everything shared with them is accurate to all standards. These will wave good bye to your programming cribs, and get your codes working properly with a quick reference lasting for merely a few minutes!

1) Cheat Sheets – jQuery


best free cheat sheets for designers and developers - jquery

2) Cheat Sheets – HTML


best free cheat sheets for designers and developers - html

3) Cheat Sheets - HTML5 Cheat Sheet


best free cheat sheets for designers and developers - HTML5

4) Cheat Sheets – CSS


best free cheat sheets for designers and developers - css

5) Cheat Sheets – CSS2


best free cheat sheets for designers and developers - css2

6) Cheat Sheets – CSS3


best free cheat sheets for designers and developers - css3

7) Cheat Sheets – JavaScript


best free cheat sheets for designers and developers - javascript

8) Cheat Sheets – Linux


best free cheat sheets for designers and developers - linux

9) Cheat Sheets –  Java


best free cheat sheets for designers and developers - java

10) Cheat Sheets - Java 8


best free cheat sheets for designers and developers - java8

11) Cheat Sheets – Perl


best free cheat sheets for designers and developers - perl

12) Cheat Sheets – PHP


best free cheat sheets for designers and developers - php

13) Cheat Sheets – Python


best free cheat sheets for designers and developers - python

14) Cheat Sheets – Ruby


best free cheat sheets for designers and developers - ruby

15) Cheat Sheets – Ruby on Rails


best free cheat sheets for designers and developers - ruby-on-rails

16) Cheat Sheets – Scala Cheat sheets 


best free cheat sheets for designers and developers - scala

17) Cheat Sheets – SQL


best free cheat sheets for designers and developers - sql

18) Cheat Sheets – My SQL


best free cheat sheets for designers and developers - my-sql

19) Cheat Sheets – C#


best free cheat sheets for designers and developers - c#

20) Cheat Sheets – SQLite


best free cheat sheets for designers and developers - sqlite

21) Cheat Sheets – C++


best free cheat sheets for designers and developers - C++

22) Cheat Sheets – Javascript and AJAX 


best free cheat sheets for designers and developers - ajax

23) Cheat Sheets – C


best free cheat sheets for designers and developers - c

24) Cheat Sheets – Unix


best free cheat sheets for designers and developers - unix

25) Cheat Sheets – Ubuntu


best free cheat sheets for designers and developers - ubuntu

26) Cheat Sheets – WordPress


best free cheat sheets for designers and developers - wordpress

27) Cheat Sheets – Nodejs


best free cheat sheets for designers and developers - nodejs

28) Cheat Sheets –  HTML and XHTML


best free cheat sheets for designers and developers - xhtml

29) Cheat Sheets – XML


best free cheat sheets for designers and developers - xml

30) Cheat Sheets – Oracle


best free cheat sheets for designers and developers - oracle

31) Cheat Sheets – NMAP


best free cheat sheets for designers and developers - nmap

32) Cheat Sheets – Mac OS X


best free cheat sheets for designers and developers - macosx

33) Cheat Sheets - Haskell


best free cheat sheets for designers and developers - haskell

34) Cheat Sheets – DOM


best free cheat sheets for designers and developers - dom

35) Cheat Sheets – Drupal


best free cheat sheets for designers and developers - drupal

36) Cheat Sheets – Oracle DB 


best free cheat sheets for designers and developers - oracledb

37) Cheat Sheets – FireFox 


best free cheat sheets for designers and developers - firefox

38) Cheat Sheets – Apache Ant


best free cheat sheets for designers and developers- apacheant

39) Cheat Sheets – Apache hadoop


best free cheat sheets for designers and developers - apache

40)  Cheat Sheets -Git


best free cheat sheets for designers and developers - git

41)  Cheat Sheets -Mathematica


best free cheat sheets for designers and developers - mathmatics

42) Cheat Sheets – RedHat Fedora


best free cheat sheets for designers and developers - fedora

43) Cheat Sheets – Unicode


best free cheat sheets for designers and developers - unicode

44) Cheat Sheets - PostgreSQL


best free cheat sheets for designers and developers - postgresql

45) Cheat Sheets – MATLAB


best free cheat sheets for designers and developers - matlab

46) Cheat Sheets - Design Patterns

47) Cheat Sheets - Django Reference Sheet

48) Cheat Sheets - Flash Quick Reference

49) Cheat Sheets - Fortran

50) Cheat Sheets - Adobe flex 3 cheat sheet

51) Cheat Sheets - Google Chrome Plus

52) Cheat Sheets – HTTP

53) Cheat Sheets - Internet Explorer

54) Cheat Sheets - JavaEE6 Reference Sheet

55) Cheat Sheets – LISP

56) Cheat Sheets - Mootools 1.3 cheat sheets

57) Cheat Sheets - Photoshop

58) Cheat Sheets - Prototype

59) Cheat Sheets – QT

60) Cheat Sheets - Shell Scrip Cheat Sheet

61) Cheat Sheets - Server Side Includes Qucik Reference

62) Cheat Sheets – VBasic Quick Ref

63) Cheat Sheets - ASPCheat Sheet

64) Cheat Sheets - WebGL Reference

65) Cheat Sheets - Microsoft NET

66) Cheat Sheets - Flash ActionScript Quick Ref

67)  Cheat Sheets - BlueprintCSS

68) Cheat Sheets – Computer Science

69) Cheat Sheets - Erlang

70) Cheat Sheets – Java Server faces 

71) Cheat Sheets - JDBC Best Practices

72) Cheat Sheets - Core-ASPNet

73) Cheat Sheets - HTML5 IndexedDB

74) Cheat Sheets - Using XML Java

75) Cheat Sheets - HTML5 Canvas Web Standard