HelloWorld -- Rokon Game Engine
로콘 게임 엔진 맛보기 1 탄
메인 액티비티(안드로이드 메인 행동^^)
public class MainActivity extends RokonActivity { public static final float GAME_WIDTH = 480f; public static final float GAME_HEIGHT = 320f; private GameScene scene; public void onCreate() { /** * Just tells rokon to go into debug mode (duh), * what that means is that it will print out * your current FPS and your own Debug.print() calls. */ debugMode(); /** * This basically forces the game to go into fullscreen * and landscape mode (this is of course optional). * (note that you can also replace it with ‘forcePortrait()’) */ forceFullscreen(); forceLandscape(); // or forcePortrait() /** * Here we set the size of the game screen, * if it is smaller or larger than * the actual device it is run on, * it will scale up or down to match it. */ setGameSize(GAME_WIDTH, GAME_HEIGHT); /** * This will make Rokon use VBO’s when drawing * (if the device supports it). * This is good because drawing VBO's is * faster than normal rendering. */ setDrawPriority(DrawPriority.PRIORITY_VBO); /** * This will set Rokon to look for graphics * in that folder (in this case 'assets/textures/'). */ setGraphicsPath("textures/"); createEngine(); } /** * ‘onLoadComplete()’ will be called * when the engine has been successfully created. * So we’ll make it load all your textures * with ‘Textures.load()’ and then setup your game scene: */ public void onLoadComplete() { Textures.load(); scene = new GameScene(); setScene(scene); } }
텍스처
public class Textures { /** * TextureAtlas : 텍스처들의 관리자 * * This will create a new texture atlas, * this is basically just a holder for textures. * * If you have many textures you might want to use more than * one atlas to not overload the hardware. * * (note however that it’s recommended to use * only one atlas at a time, * therefore you shouldn’t use textures from * two different atlases in the same scene/map/whatever) */ public static TextureAtlas atlas; public static Texture background; public static void load() { // TODO Auto-generated method stub //TextureAtlas atlas = new TextureAtlas(); /** * Here we’ll add the background texture to our atlas. * (note that it’s recommended to add the textures * in order of size, ie add the biggest one first, * and the smallest one last) */ background = new Texture("background.png"); atlas.insert( background ); /** * * This marks the atlas as complete, meaning that after you call this, * you cannot add any more textures to the atlas. */ atlas.complete(); } }
게임화면
public class GameScene extends Scene { private FixedBackground background; public GameScene() { super(); // TODO Auto-generated constructor stub background = new FixedBackground(Textures.background); setBackground(background); } @Override public void onGameLoop() { // TODO Auto-generated method stub } @Override public void onPause() { // TODO Auto-generated method stub } @Override public void onReady() { // TODO Auto-generated method stub } @Override public void onResume() { // TODO Auto-generated method stub } }
'0.일반개발' 카테고리의 다른 글
Using Touch Input -- Rokon Game Engine (0) | 2010.09.29 |
---|---|
Using Sprites -- Rokon Game Engine (0) | 2010.09.29 |
Rokon is an open source (New BSD license) 2D OpenGL game engine for Android. (0) | 2010.09.29 |
GLSurfaceView.Renderer (0) | 2010.09.29 |
HTML 제거하기 (0) | 2010.09.28 |