AndEngine Divide Classes the OO way?

Put your problem here if it does not fit any of the other categories.

AndEngine Divide Classes the OO way?

Postby Sterallures » Sat Jun 30, 2012 9:43 am

I'm developing an AndEngine game and I've got a working sample now. The thing is I've still got everything in 1 class and I want to divide it up, for one reason it's easier and better readable.

I'm just wondering what's the best approach to divide everything up in seperate classes.
Is it OK to give the Activity as a parameter?

I'm loading the BitmapTextures in the onCreateResources() like so:

MainActivity.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2. public void onCreateResources() {
  3. this.mPlayerTexture = new BitmapTextureAtlas(this.getTextureManager(), 64, 64, TextureOptions.BILINEAR);
  4.         this.mPlayerTextureRegion =
  5.             BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mPlayerTexture, this, "hero_small.png", 0, 0, 1,
  6.                 1);
  7.         this.mPlayerTexture.load();
  8. }
  9.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


now I'd like to do the following:

Player.java
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. public void initPlayer(MainActivity activity, Context context) {
  2.                 this.mPlayerTexture = new BitmapTextureAtlas(activity.getTextureManager(), 64, 64, TextureOptions.BILINEAR);
  3.         this.mPlayerTextureRegion =
  4.             BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(this.mPlayerTexture, activity, "hero_small.png", 0, 0, 1,
  5.                 1);
  6.         this.mPlayerTexture.load();
  7.         }
  8.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


I'm just wondering if it's a good approach to do it like this or just load all the resources in the MainActivity and not use an Activity as a parameter?
Sterallures
Freshman
Freshman
 
Posts: 6
Joined: Thu May 20, 2010 9:37 pm

Top

Return to Other Coding-Problems

Who is online

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