Eclipse, AndEngine and HelloWorld!!!

  ... tutorials on how to use AndEngine.

Re: Eclipse, AndEngine and HelloWorld!!!

Postby kirilz » Wed Sep 22, 2010 12:37 am

I have the same problem as GalaxyKnight but opening a new project does not fix it for me:
https://docs.google.com/leaf?id=0Bx7PU-xc2mycMzBlMTA3NWQtMWUwZC00NjVlLTg5MzktZDgzODhiMmM5Y2M4&hl=en

I did try the suggestions of the IDE - added one last parameter to the engine (false), used registerPostFrameHandler instead of regusterUpdateHandler() and finally used the stock setBackgroundColor() method.
The code compiles and crashes every time on startup. I comment tagged the registerPostFrameHandler(I know, bad practice, but I was very annoyed) and the application started, stayed for a few seconds and then crashed.

Any suggestions? I am totally out of ideas, especially since I cannot find a reference for the engine itself.

Thanks in advance.
kirilz
 
Posts: 1
Joined: Tue Sep 21, 2010 11:50 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby oldpond » Sun Oct 17, 2010 4:05 pm

Excellent tutorial! Thanks for taking the time.

Is anyone else getting a black background instead of the expected blue?
oldpond
 
Posts: 13
Joined: Sun Oct 17, 2010 3:51 pm
Location: Winnipeg, Canada

Re: Eclipse, AndEngine and HelloWorld!!!

Postby tamas » Sun Nov 07, 2010 7:08 pm

Hello

"Now you need to add the Library to your Projects Build Path. This is very easy, so follow these steps:
1. Open your lib folder
2. Right Click on the andengine.jar
3. Select Build Path -> Add To Build Path"

After adding a jar to build path, I get "Conversion to Dalvik format failed with error 1".
I tried it with several eclipse versions.: 3.5, 3.5.2, 3.6. With 32 bit, and 64 bit java. On ubuntu 64bit, ubuntu 32bit, win 7 64bit.

I get this error with some other jar files too, even with jar files generated by me, so it's not a new problem, but it started to bug me, after I started using andengine. Usually it goes away after I clean the project, but not this time.
The obvious workaround is just adding the whole andengine project to the build path instead of a jar, it works like that, but that should not be necessary.

Maybe someone could point out what's wrong.

Here is the whole error message:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. [2010-11-07 17:59:53 - game]    at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
  2. [2010-11-07 17:59:53 - game]    at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
  3. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.processClass(Main.java:299)
  4. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:276)
  5. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.access$100(Main.java:56)
  6. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:228)
  7. [2010-11-07 17:59:53 - game]    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:245)
  8. [2010-11-07 17:59:53 - game]    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
  9. [2010-11-07 17:59:53 - game]    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
  10. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.processOne(Main.java:245)
  11. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:183)
  12. [2010-11-07 17:59:53 - game]    at com.android.dx.command.dexer.Main.run(Main.java:139)
  13. [2010-11-07 17:59:53 - game]    at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
  14. [2010-11-07 17:59:53 - game]    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
  15. [2010-11-07 17:59:53 - game]    at java.lang.reflect.Method.invoke(Unknown Source)
  16. [2010-11-07 17:59:53 - game]    at com.android.ide.eclipse.adt.internal.sdk.DexWrapper.run(Unknown Source)
  17. [2010-11-07 17:59:53 - game]    at com.android.ide.eclipse.adt.internal.build.PostCompilerHelper.executeDx(Unknown Source)
  18. [2010-11-07 17:59:53 - game]    at com.android.ide.eclipse.adt.internal.build.PostCompilerBuilder.build(Unknown Source)
  19. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:627)
  20. [2010-11-07 17:59:53 - game]    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
  21. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:170)
  22. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:201)
  23. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager$1.run(BuildManager.java:253)
  24. [2010-11-07 17:59:53 - game]    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
  25. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:256)
  26. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager.basicBuildLoop(BuildManager.java:309)
  27. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:341)
  28. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.AutoBuildJob.doBuild(AutoBuildJob.java:140)
  29. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.events.AutoBuildJob.run(AutoBuildJob.java:238)
  30. [2010-11-07 17:59:53 - game]    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
  31. [2010-11-07 17:59:53 - game] 1 error; aborting
  32. [2010-11-07 17:59:53 - game] Conversion to Dalvik format failed with error 1
Parsed in 0.015 seconds, using GeSHi 1.0.8.4
tamas
 
Posts: 10
Joined: Sun Nov 07, 2010 11:14 am
Location: Hungary

Re: Eclipse, AndEngine and HelloWorld!!!

Postby a2k » Fri Nov 19, 2010 1:54 am

wrothgar wrote:Update: I found my problem.

The problem was that I forget (actually didn't know) to add the .so file in the libs/armeabi directory. Once I did that it seems to be running fine. I found the answer in the Physics 2d forum.

I am very excited to keep playing with this engine and seeing what I can do and maybe get my game idea off the ground.

Thanks!


I wanted to confirm this solution, since it bit me for quite a while too. I also had to restart Eclipse. I'm not sure why, but it could possibly have been because I got the debugger in a confused state. Also, for those curious as to what an .so file is, it's the Unix version of a Windows dll, called a "shared object". Since Box2D is in native code, the andengine extension uses JNI to hook into the .so library.

Thanks, Nicolas! This engine is awesome!
a2k
 
Posts: 2
Joined: Fri Nov 19, 2010 1:48 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby manoelramon » Sat Nov 27, 2010 12:23 am

Mimminito wrote:It seems a few people who come here are a little confused as to how to get started with AndEngine, Eclipse, and even Android/Java in general. So I thought I would post this up for people to get started with.

First off, check out the following topic by Nicolas. Its about getting started with AndEngine and how to download the Engine:
http://www.andengine.org/forums/tutorials/getting-started-with-andengine-t11.html

Once you have checked that out, and you are still a little unsure about stuff, check the tips below.

Tip 1 - Eclipse
Eclipse is the IDE of choice for Android development. So it makes sense to use Google's recommended IDE, which also comes with a Plugin, allowing you to easily setup Android Development, your Virtual Android Devices/Emulators, and much more.
You can download Eclipse from the following location:
http://www.eclipse.org/downloads/

Please I am a beginner on this engine and I am not able to run nothing :((

My Eclipse + android sdk work perfectly.. I am using android 2.1.. I loaded the andengine.jar, followed all process explained on your tutorial, but when I started I just see force closes.

I tried a simple example like https://andengineexamples.googlecode.co ... ample.java

my logcat says:

I/ActivityManager( 53): Start proc org.anddev.andengine.examples for activity org.anddev.andengine.examples/.PhysicsExample: pid=271 uid=10030 gids={1015}
D/dalvikvm( 264): LinearAlloc 0x0 used 637292 of 5242880 (12%)
D/AndroidRuntime( 271): Shutting down VM
W/dalvikvm( 271): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
E/AndroidRuntime( 271): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 271): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.anddev.andengine.examples/org.anddev.andengine.examples.PhysicsExample}: java.lang.ClassNotFoundException: org.anddev.andengine.examples.PhysicsExample in loader dalvik.system.PathClassLoader@43d0b300
E/AndroidRuntime( 271): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2417)
E/AndroidRuntime( 271): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
E/AndroidRuntime( 271): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
E/AndroidRuntime( 271): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
E/AndroidRuntime( 271): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 271): at android.os.Looper.loop(Looper.java:123)
E/AndroidRuntime( 271): at android.app.ActivityThread.main(ActivityThread.java:4363)
E/AndroidRuntime( 271): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 271): at java.lang.reflect.Method.invoke(Method.java:521)
E/AndroidRuntime( 271): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
E/AndroidRuntime( 271): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
E/AndroidRuntime( 271): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 271): Caused by: java.lang.ClassNotFoundException: org.anddev.andengine.examples.PhysicsExample in loader dalvik.system.PathClassLoader@43d0b300
E/AndroidRuntime( 271): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
E/AndroidRuntime( 271): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
E/AndroidRuntime( 271): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
E/AndroidRuntime( 271): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 271): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2409)
E/AndroidRuntime( 271): ... 11 more
I/Process ( 53): Sending signal. PID: 271 SIG: 3
I/dalvikvm( 271): threadid=7: reacting to signal 3
I/dalvikvm( 271): Wrote stack trace to '/data/anr/traces.txt'
W/ActivityManager( 53): Activity idle timeout for HistoryRecord{43d60fc0 org.anddev.andengine.examples/.PhysicsExample}
D/dalvikvm( 105): GC freed 3334 objects / 206136 bytes in 233ms


Any help is very welcome!

Once you have that downloaded, install it, and then check the following guide which will help you with setting up your environment:
http://developer.android.com/sdk/installing.html

Now you should be ready to go with some Android Development! So onto Tip 2.

Tip 2 - Getting AndEngine
Nicolas has made a smart choice with the way he distributes AndEngine. He uses Mercurial, which is a Version Control System for projects. It can be directly used with Google Code, and thats a massive plus!! It also has a Plugin for use within Eclipse, which you can download/setup by following the guide below:
http://www.javaforge.com/project/HGE

Once you have this installed, its time to download the AndEngine examples. This is where you should spend a good few hours looking through all of the Examples, familiarizing yourself with the structure of AndEngine and how you would go about accomplishing various tasks.
To download the AndEngine Examples, following these steps:

1. File -> New Project
2. Select the Clone Existing Mercurial Repository under the Mercurial folder
3. In the URL field, copy and paste the following link:
https://andengineexamples.googlecode.com/hg/
4. Optional - If you want to change the Local Projects Name, enter your preferred name in the Clone Directory Name field.
5. Press Next. This should then be shown a screen with what will be downloaded.
6. Press Next and then Finish to pull the AndEngineExamples down.

Well done, you now have the AndEngine Examples on your system!
Note: If you cannot see the AndEngine Examples Project within your Eclipse Worksapce, then try to import the project from your workspace. You can do this by selecting File -> Import -> Existing Projects Into Workspace.

Right, so we now have the AndEngine Examples on our system. So go away, and like I said before, look through them all. See what they all do, build them and try them on your Phone or Emulator. Once you are done, then move onto the next tip.

Tip 3 - Hello World
So, now that we have everything setup, and that we have had a look at the Examples for AndEngine, you are going to want to try and code something yourself. Well, your in luck. This tip will show you how to create your own Project, and display a simple Sprite on the Screen.

So, first up, create a New Project! Go to File -> New, and the select Android Project from the Android folder. Choose a name for your Project, such as "HelloWorld".

Now this is done, we need to import the AndEngine Library into out project so that we can actually use it! Follow these steps:
1. Right Click on your Projects Name
2. Select New -> Folder and create a folder called lib
3. Open up your AndEngine Examples Project, and go to the lib folder.
4. Copy the andengine.jar
5. Past the andengine.jar into your newly created lib folder.

Now you need to add the Library to your Projects Build Path. This is very easy, so follow these steps:
1. Open your lib folder
2. Right Click on the andengine.jar
3. Select Build Path -> Add To Build Path

You now have the AndEngine Library setup in your project! So lets get down to some code

Open up the default Activity for your Project, which should be called HelloWorld.java if you named your project like I said. Now, DELETE EVERYTHING from this file, EXCEPT the package line at the top of the file.
Once you have done this, copy and paste the following code into your file:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public class HelloWorld extends BaseGameActivity {
  2.         // ===========================================================
  3.         // Constants
  4.         // ===========================================================
  5.  
  6.         private static final int CAMERA_WIDTH = 720;
  7.         private static final int CAMERA_HEIGHT = 480;
  8.  
  9.         // ===========================================================
  10.         // Fields
  11.         // ===========================================================
  12.  
  13.         private Camera mCamera;
  14.  
  15.         // ===========================================================
  16.         // Constructors
  17.         // ===========================================================
  18.  
  19.         // ===========================================================
  20.         // Getter & Setter
  21.         // ===========================================================
  22.  
  23.         // ===========================================================
  24.         // Methods for/from SuperClass/Interfaces
  25.         // ===========================================================
  26.  
  27.         @Override
  28.         public Engine onLoadEngine() {
  29.                 this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  30.                 return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
  31.         }
  32.  
  33.         @Override
  34.         public void onLoadResources() {
  35.         }
  36.  
  37.         @Override
  38.         public Scene onLoadScene() {
  39.                 this.mEngine.registerUpdateHandler(new FPSLogger());
  40.  
  41.                 final Scene scene = new Scene(1);
  42.                 scene.setBackground(new ColorBackground(0, 0, 0.8784f));
  43.  
  44.                 return scene;
  45.         }
  46.  
  47.         @Override
  48.         public void onLoadComplete() {
  49.  
  50.         }
  51.  
  52.         // ===========================================================
  53.         // Methods
  54.         // ===========================================================
  55.  
  56.         // ===========================================================
  57.         // Inner and Anonymous Classes
  58.         // ===========================================================
  59. }
  60.  
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


Then press Ctrl+Shift+O and your project should sort all of the Import Statements out for you.

Before you build, make sure you add the following line into youe AndroidManifest.xml file:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.WAKE_LOCK"/>
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

This allows AndEngine to run and use the permissions it needs.

Now, try to build and run this. If it builds properly, it should run on your Phone/Emulator and display a bluey background. If so, well done you have written your first AndEngine Project! Its as simple as that. If you want do display a Sprite, check out the following SpriteExample which will display a Sprite on your Screen.
Sprite Example

To get use to Touch, check out the following examples, and try to add them to your Project:
Sprite Remove Example
Touch Drag Example

Thats the end of this tutorial. If you feel more needs to be added, such as how to do something within AndEngine, let me know and ill add it in.

Otherwise see you next time!
manoelramon
 
Posts: 12
Joined: Sat Nov 27, 2010 12:18 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby toorddroid » Thu Dec 02, 2010 5:55 am

I'm having problems with any project trying to load resources. I've tried this hello world + something with shapes (i.e. no resources loaded) and ran fine. As soon as I try run any of the samples that load resources (including the image sprite), it force closes in the emulators. Any help would be greatly appreciated.
toorddroid
 
Posts: 5
Joined: Thu Dec 02, 2010 4:19 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby riacheslav » Fri Dec 03, 2010 3:06 am

Hi,

Having some trouble getting underway. When I try to download the MercurialEclipse plug-in in the Eclipse->Help->Install New Software menu I get an error:
Cannot complete the install because some dependencies are not satisfiable

It balks at the "Windows Binaries for Mercurial (Recommended)." Then when I try to Clone an existing Mercurial repository I get shot down because:
Process start failed: hg -y debuginstall
Cannot run program "hg": error-2, No such file or directory.

Is Mercurial not supported for MacOS? I've been searching all over and can't find anything that tells me that one way or another. How would I get the repository if not through Mercurial?

Thanks greatly for any help,
Richard

NOTE!: Problem solved.
MacOS version is at: http://mercurial.selenic.com/downloads/
riacheslav
 
Posts: 7
Joined: Thu Dec 02, 2010 10:47 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby riacheslav » Tue Dec 07, 2010 4:20 am

When I try to set up and run the HelloWorld example here (the one that starts with the line: "public class HelloWorld extends BaseGameActivity {") all the @Override methods (onLoadEngine(), onLoadResources(), etc) show errors: "must override a superclass method." If I simply remove the @Override it will run and I get the blue background. But something is not right there. I can see those methods in the Interface, and I am extending the BaseGameActivity class. File in the wrong place, or a mistake in my imports?

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.blahblah.Foo;
  2.  
  3. import org.anddev.andengine.engine.Engine;
  4. import org.anddev.andengine.engine.camera.Camera;
  5. import org.anddev.andengine.engine.options.EngineOptions;
  6. import org.anddev.andengine.engine.options.EngineOptions.ScreenOrientation;
  7. import org.anddev.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy;
  8. import org.anddev.andengine.entity.scene.Scene;
  9. import org.anddev.andengine.entity.scene.background.ColorBackground;
  10. import org.anddev.andengine.entity.util.FPSLogger;
  11. import org.anddev.andengine.ui.activity.BaseGameActivity;
  12.  
  13. public class Foo extends BaseGameActivity {
  14.    // ===========================================================
  15.    // Constants
  16.    // ===========================================================
  17.    private static final int CAMERA_WIDTH = 720;
  18.    private static final int CAMERA_HEIGHT = 480;
  19.  
  20.    // ===========================================================
  21.    // Fields
  22.    // ===========================================================
  23.    private Camera mCamera;
  24.  
  25.    // ===========================================================
  26.    // Constructors
  27.    // ===========================================================
  28.  
  29.    // ===========================================================
  30.    // Getter & Setter
  31.    // ===========================================================
  32.  
  33.    // ===========================================================
  34.    // Methods for/from SuperClass/Interfaces
  35.    // ===========================================================
  36.  
  37.    @Override
  38.    public Engine onLoadEngine() {
  39.       this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
  40.       return new Engine(new EngineOptions(true, ScreenOrientation.LANDSCAPE, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
  41.    }
  42.  
  43.    @Override
  44.    public void onLoadResources() {
  45.    }
  46.  
  47.    @Override
  48.    public Scene onLoadScene() {
  49.       this.mEngine.registerUpdateHandler(new FPSLogger());
  50.       final Scene scene = new Scene(1);
  51.       scene.setBackground(new ColorBackground(0, 0, 0.8784f));
  52.       return scene;
  53.    }
  54.  
  55.    @Override
  56.    public void onLoadComplete() {
  57.    }
  58.  
  59.    // ===========================================================
  60.    // Methods
  61.    // ===========================================================
  62.  
  63.    // ===========================================================
  64.    // Inner and Anonymous Classes
  65.    // ===========================================================
  66. }
  67.  
Parsed in 0.013 seconds, using GeSHi 1.0.8.4


I did add the line: <uses-permission android:name="android.permission.WAKE_LOCK"/> to the Manifest XML-- but not sure if it is in the right place. I don't see any instructions on where to put most of the code here; where in the Manifest should that go? I pushed it around until I didn't see any errors. Maybe it doesn't matter, but, well, I doubt it.

Moving to the Sprite spawning tutorial, (at: tutorials/using-timer-s-sprite-spawn-example-t463.html), I have:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. /**
  2.     * Creates a Timer Handler used to Spawn Sprites
  3.     */
  4.    private void createSpriteSpawnTimeHandler()
  5.    {
  6.       TimerHandler spriteTimerHandler;
  7.      
  8.       this.getEngine().registerUpdateHandler(spriteTimerHandler = new TimerHandler(200, new ITimerCallback()
  9.       {        
  10.          
  11.           public void onTimePassed(final TimerHandler pTimerHandler)
  12.           {
  13.             spriteTimerHandler.reset();
  14.            
  15.             //Random Position Generator
  16.             final float xPos = MathUtils.random(30.0f, (CAMERA_WIDTH - 30.0f));
  17.             final float yPos = MathUtils.random(30.0f, (CAMERA_HEIGHT - 30.0f));
  18.            
  19.             createSprite(xPos, yPos);
  20.           }
  21.       }));
  22.    }
  23.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


which rejects the line: spriteTimerHandler.reset(); because: "Cannot refer to a non-final variable spriteTimerHandler inside an inner class defined in a different method." If I move the declaration "TimerHandler spriteTimerHandler;" up into the Fields declarations above, no errors. No sprites either though.
These are just not the problems I'm expecting, and no one else seems to be having them (or isn't complaining!) So again, please forgive my newbieness. I feel there must be some setup/import/project management I'm doing wrong, because the code is so straightforward...

Sorry for the long post, and thank you for any help.

Richard
riacheslav
 
Posts: 7
Joined: Thu Dec 02, 2010 10:47 pm

Re: Eclipse, AndEngine and HelloWorld!!!

Postby dear_gamemaster » Tue Dec 07, 2010 7:06 pm

Try making the "TimerHandler spriteTimerHandle" final.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.     final TimerHandler spriteTimerHandler = new TimerHandler(200, new ITimerCallback() {
  2.         public void onTimePassed(final TimerHandler pTimerHandler) {        
  3.             ...
  4.         }
  5.     });
  6.     this.getEngine().registerUpdateHandler(spriteTimerHandler);
  7.  
Parsed in 0.010 seconds, using GeSHi 1.0.8.4


Or you can just use the argument from "onTimePassed" which is - by all chance - the same TimerHandler and it is final, just for the convenience. :)

Hope I helped..
dear_gamemaster
 
Posts: 4
Joined: Tue Dec 07, 2010 2:03 am

Re: Eclipse, AndEngine and HelloWorld!!!

Postby riacheslav » Tue Dec 07, 2010 9:14 pm

Thanks gamemaster.

It didn't work for me, but using Ted Hughes post in the next Tutorial: "Sprite Spawn" did work. I'll take the discussion to that forum for that tho.

The other problem is still a concern: I have to eliminate all "@Override" statements. Then it runs fine. But doesn't seem right. Any thoughts much appreciated.
riacheslav
 
Posts: 7
Joined: Thu Dec 02, 2010 10:47 pm

PreviousNext

Return to Tutorials

Who is online

Users browsing this forum: Google [Bot] and 9 guests