OSDN Git Service

[fixed] hello world example
authorbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Tue, 2 Nov 2010 00:33:55 +0000 (00:33 +0000)
committerbadlogicgames <badlogicgames@6c4fd544-2939-11df-bb46-9574ba5d0bfa>
Tue, 2 Nov 2010 00:33:55 +0000 (00:33 +0000)
demos/helloworld/gdx-helloworld/.classpath
demos/helloworld/gdx-helloworld/libs/gdx-backend-jogl.jar [moved from demos/helloworld/gdx-helloworld/libs/gdx-backend-desktop.jar with 96% similarity]
demos/helloworld/gdx-helloworld/libs/gdx-sources.jar
demos/helloworld/gdx-helloworld/libs/gdx.dll
demos/helloworld/gdx-helloworld/libs/gdx.jar
demos/helloworld/gdx-helloworld/src/com/badlogic/gdx/helloworld/HelloWorld.java
demos/helloworld/gdx-helloworld/src/com/badlogic/gdx/helloworld/HelloWorldDesktop.java

index c9f34d2..05c8dbd 100644 (file)
@@ -2,11 +2,11 @@
 <classpath>\r
        <classpathentry excluding="**/.svn/*" kind="src" path="src"/>\r
        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>\r
-       <classpathentry kind="lib" path="libs/gdx-backend-desktop.jar"/>\r
        <classpathentry kind="lib" path="libs/gdx.jar" sourcepath="libs/gdx-sources.jar">\r
                <attributes>\r
                        <attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="gdx-helloworld/libs"/>\r
                </attributes>\r
        </classpathentry>\r
+       <classpathentry kind="lib" path="libs/gdx-backend-jogl.jar"/>\r
        <classpathentry kind="output" path="bin"/>\r
 </classpath>\r
similarity index 96%
rename from demos/helloworld/gdx-helloworld/libs/gdx-backend-desktop.jar
rename to demos/helloworld/gdx-helloworld/libs/gdx-backend-jogl.jar
index 8f5cc36..ce7747b 100644 (file)
Binary files a/demos/helloworld/gdx-helloworld/libs/gdx-backend-desktop.jar and b/demos/helloworld/gdx-helloworld/libs/gdx-backend-jogl.jar differ
index 63f947c..5d6856a 100644 (file)
Binary files a/demos/helloworld/gdx-helloworld/libs/gdx-sources.jar and b/demos/helloworld/gdx-helloworld/libs/gdx-sources.jar differ
index 1e4ee48..b9dd1f2 100644 (file)
Binary files a/demos/helloworld/gdx-helloworld/libs/gdx.dll and b/demos/helloworld/gdx-helloworld/libs/gdx.dll differ
index 9bff1e3..1cb7bf9 100644 (file)
Binary files a/demos/helloworld/gdx-helloworld/libs/gdx.jar and b/demos/helloworld/gdx-helloworld/libs/gdx.jar differ
index 56c1544..5e7cdd2 100644 (file)
 \r
 package com.badlogic.gdx.helloworld;\r
 \r
-import com.badlogic.gdx.Files.FileType;\r
+import com.badlogic.gdx.ApplicationListener;\r
 import com.badlogic.gdx.Gdx;\r
-import com.badlogic.gdx.RenderListener;\r
+import com.badlogic.gdx.Files.FileType;\r
+import com.badlogic.gdx.graphics.BitmapFont;\r
 import com.badlogic.gdx.graphics.Color;\r
-import com.badlogic.gdx.graphics.Font;\r
-import com.badlogic.gdx.graphics.Font.FontStyle;\r
 import com.badlogic.gdx.graphics.GL10;\r
 import com.badlogic.gdx.graphics.SpriteBatch;\r
 import com.badlogic.gdx.graphics.Texture;\r
@@ -26,15 +25,15 @@ import com.badlogic.gdx.graphics.Texture.TextureFilter;
 import com.badlogic.gdx.graphics.Texture.TextureWrap;\r
 import com.badlogic.gdx.math.Vector2;\r
 \r
-public class HelloWorld implements RenderListener {\r
+public class HelloWorld implements ApplicationListener {\r
        boolean initialized = false;\r
        SpriteBatch spriteBatch;\r
        Texture texture;\r
-       Font font;\r
+       BitmapFont font;\r
        Vector2 textPosition = new Vector2(100, 100);\r
        Vector2 textDirection = new Vector2(1, 1);\r
 \r
-       @Override public void dispose () {\r
+       @Override public void destroy () {\r
 \r
        }\r
 \r
@@ -52,20 +51,30 @@ public class HelloWorld implements RenderListener {
                spriteBatch.begin();\r
                spriteBatch.draw(texture, centerX - texture.getWidth() / 2, centerY - texture.getHeight() / 2, 0, 0, texture.getWidth(),\r
                        texture.getHeight(), Color.WHITE);\r
-               spriteBatch.drawText(font, "Hello World!", (int)textPosition.x, (int)textPosition.y, Color.RED);\r
+               font.draw(spriteBatch, "Hello World!", (int)textPosition.x, (int)textPosition.y, Color.RED);            \r
                spriteBatch.end();\r
        }\r
 \r
-       @Override public void surfaceChanged (int width, int height) {\r
+       @Override public void resize (int width, int height) {\r
 \r
        }\r
 \r
-       @Override public void surfaceCreated () {\r
+       @Override public void create () {\r
                if (!initialized) {\r
-                       font = Gdx.graphics.newFont("Arial", 32, FontStyle.Plain);\r
+                       font = new BitmapFont();\r
                        texture = Gdx.graphics.newTexture(Gdx.files.getFileHandle("data/badlogic.jpg", FileType.Internal), TextureFilter.MipMap,\r
                                TextureFilter.Linear, TextureWrap.ClampToEdge, TextureWrap.ClampToEdge);\r
                        spriteBatch = new SpriteBatch();\r
                }\r
        }\r
+\r
+       @Override\r
+       public void pause() {\r
+               \r
+       }\r
+\r
+       @Override\r
+       public void resume() {\r
+               \r
+       }\r
 }\r
index adc5955..83530b2 100644 (file)
 \r
 package com.badlogic.gdx.helloworld;\r
 \r
-import com.badlogic.gdx.backends.desktop.JoglApplication;\r
+import com.badlogic.gdx.backends.jogl.JoglApplication;\r
 \r
 public class HelloWorldDesktop {\r
        public static void main (String[] argv) {\r
-               JoglApplication app = new JoglApplication("Hello World", 480, 320, false);\r
-               app.getGraphics().setRenderListener(new HelloWorld());\r
+               new JoglApplication(new HelloWorld(), "Hello World", 480, 320, false);          \r
        }\r
 }\r