Updated PhysicsExample with Triangle and Hexagon bodies.

  ... information about changes and new features of AndEngine,

Updated PhysicsExample with Triangle and Hexagon bodies.

Postby Nicolas Gramlich » Thu Aug 05, 2010 10:15 pm

Hello Community,

I noticed that the creation of custom polygons for Box2D was a big problem that was requested a couple of times.

I modified the PhysicsExample to also create triangle-bodies and hexagon-bodies.
See:
box2d_polygonshapes.png
Box, Circle, Triangle and Hexagon Shapes in one Scene.
box2d_polygonshapes.png (106.11 KiB) Viewed 1828 times


Always remember that the vertices of the Polygon(Shape) you are defining have to be relative to the center of the (AndEngine-)Shape :!:

Hope this helped some of you :)

Best Regards,
Nicolas
Nicolas Gramlich
Site Admin
 
Posts: 1734
Joined: Mon Jun 07, 2010 6:20 pm
Location: Schriesheim, Germany

Re: Updated PhysicsExample with Triangle and Hexagon bodies.

Postby anindo » Fri Jan 28, 2011 12:19 pm

I just tried building the source from the above post, and the app builds fine with minor edits, but crashes at line 118 of your sample code:
PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef);


The logcat trace shows that method org.anddev.andengine.entity.shape.IShape.getVelocityX is missing,


01-28 15:32:34.237: ERROR/AndroidRuntime(264): Uncaught handler: thread main exiting due to uncaught exception
01-28 15:32:34.295: ERROR/AndroidRuntime(264): java.lang.NoSuchMethodError: org.anddev.andengine.entity.shape.IShape.getVelocityX
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at org.anddev.andengine.extension.physics.box2d.PhysicsFactory.createBoxBody(PhysicsFactory.java:87)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at org.anddev.andengine.extension.physics.box2d.PhysicsFactory.createBoxBody(PhysicsFactory.java:76)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at com.SmartPhoneGizmos.BalloonWallpaper.BalloonWallpaper.onLoadScene(BalloonWallpaper.java:132)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at org.anddev.andengine.extension.ui.livewallpaper.BaseLiveWallpaperService.onCreate(BaseLiveWallpaperService.java:47)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.app.ActivityThread.handleCreateService(ActivityThread.java:2780)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.app.ActivityThread.access$3200(ActivityThread.java:119)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1917)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.os.Handler.dispatchMessage(Handler.java:99)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.os.Looper.loop(Looper.java:123)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at java.lang.reflect.Method.invokeNative(Native Method)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at java.lang.reflect.Method.invoke(Method.java:521)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-28 15:32:34.295: ERROR/AndroidRuntime(264): at dalvik.system.NativeStart.main(Native Method)



So what am I doing wrong here?


Additional info:
  • I picked up the latest versions of the engine and box2d wrapper .jar files, and put the .so files into the /libs/armebi folder.
  • The "minor edits" referred to above include addressing the deprecated getBottomLayer() and removed addEntity()


Please help...

Thanks!
anindo
 
Posts: 3
Joined: Tue Jan 25, 2011 10:07 am


Return to Updates

Who is online

Users browsing this forum: No registered users and 4 guests