SpriteBatch -> 2x performance improvement anyone?

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

How do you like the SpriteBatch feature?

I waited for this for my whole life!!
48
49%
I'll use it in my next project!
27
28%
I don't know... yet.
22
22%
I don't need it, can I have a beer instead?
1
1%
 
Total votes : 98

Re: SpriteBatch -> 2x performance improvement anyone?

Postby bermuda2810 » Tue Aug 02, 2011 12:00 pm

Hi, Nicolas Gramlich
First time, im sorry about my E
I'm using SpriteBatch. And i have seen example of SpriteBatch in http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/SpriteBatchExample.java
but when I test it ,occuring bug :
Syntax: [ Download ] [ Hide ]
  1. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): FATAL EXCEPTION: GLThread 
  2. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): java.lang.NoSuchMethodError: org.anddev.andengine.entity.sprite.batch.SpriteBatch.drawVertices 
  3. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.sprite.batch.SpriteBatch.doDraw(SpriteBatch.java:100) 
  4. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:991) 
  5. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDraw(Entity.java:875) 
  6. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDrawChildren(Entity.java:1008) 
  7. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDrawChildren(Entity.java:1000) 
  8. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:993) 
  9. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.scene.Scene.onManagedDraw(Scene.java:233) 
bermuda2810
 
Posts: 2
Joined: Thu Apr 28, 2011 4:06 pm
Location: VietNam

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Nicolas Gramlich » Thu Aug 04, 2011 3:51 am

Hi,

bermuda2810 wrote:Hi, Nicolas Gramlich
First time, im sorry about my E
I'm using SpriteBatch. And i have seen example of SpriteBatch in http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/SpriteBatchExample.java
but when I test it ,occuring bug :
Syntax: [ Download ] [ Hide ]
  1. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): FATAL EXCEPTION: GLThread 
  2. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): java.lang.NoSuchMethodError: org.anddev.andengine.entity.sprite.batch.SpriteBatch.drawVertices 
  3. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.sprite.batch.SpriteBatch.doDraw(SpriteBatch.java:100) 
  4. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:991) 
  5. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDraw(Entity.java:875) 
  6. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDrawChildren(Entity.java:1008) 
  7. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDrawChildren(Entity.java:1000) 
  8. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:993) 
  9. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.scene.Scene.onManagedDraw(Scene.java:233) 

I'm curious how that would have even compiled o_O...
Can anyone confirm this :?:

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

Re: SpriteBatch -> 2x performance improvement anyone?

Postby bonusbob » Wed Aug 10, 2011 10:54 pm

Is there someway to change the capacity of the SpriteBatch/SpriteGroup after it is created?
Also, can you attach another SpriteBatch to a SpriteBatch?
bonusbob
 
Posts: 23
Joined: Fri Dec 31, 2010 4:40 pm

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Anilin Reddy » Fri Aug 19, 2011 5:33 pm

Nicolas Gramlich wrote:Hi,

bermuda2810 wrote:Hi, Nicolas Gramlich
First time, im sorry about my E
I'm using SpriteBatch. And i have seen example of SpriteBatch in http://code.google.com/p/andengineexamples/source/browse/src/org/anddev/andengine/examples/SpriteBatchExample.java
but when I test it ,occuring bug :
Syntax: [ Download ] [ Hide ]
  1. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): FATAL EXCEPTION: GLThread 
  2. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): java.lang.NoSuchMethodError: org.anddev.andengine.entity.sprite.batch.SpriteBatch.drawVertices 
  3. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.sprite.batch.SpriteBatch.doDraw(SpriteBatch.java:100) 
  4. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:991) 
  5. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDraw(Entity.java:875) 
  6. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDrawChildren(Entity.java:1008) 
  7. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onDrawChildren(Entity.java:1000) 
  8. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.Entity.onManagedDraw(Entity.java:993) 
  9. 08-02 16:43:25.296: ERROR/AndroidRuntime(347): at org.anddev.andengine.entity.scene.Scene.onManagedDraw(Scene.java:233) 

I'm curious how that would have even compiled o_O...
Can anyone confirm this :?:

Best Regards,
Nicolas


I got the same issue. 'Fixed' it by removing the @SuppressWarnings annotation on the drawVertices method in the SpriteBatch class.
Changed from: private void drawVertices(final GL10 pGL, @SuppressWarnings("unused") final Camera pCamera)
to: private void drawVertices(final GL10 pGL, final Camera pCamera)

recompiled it, and it worked. I have no idea why that caused the issue though....
Anilin Reddy
 
Posts: 1
Joined: Thu Jan 27, 2011 7:30 am

Re: SpriteBatch -> 2x performance improvement anyone?

Postby lopez1_de » Mon Sep 12, 2011 1:23 pm

Same problem here. Fixed it with the solution from Anilin.
lopez1_de
 
Posts: 69
Joined: Fri Jun 10, 2011 9:27 am

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Mathew » Sat Oct 29, 2011 12:50 pm

Hello, I decided to implement SpriteBatch feature to improve performance of my game.

Im adding my "coins" sprites to the sprite batch with this way:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. coinsBatch.draw(new Coin(x, y, width, height, groundTilesNormalTextureRegion));
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


It works, they are drawn on the scene, but they act like normal sprite (Coin class is extension of the sprite, with collision check, and entity modifier)

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         private class Coin extends Sprite
  2.         {              
  3.                 private boolean received = false;
  4.                
  5.                 public Coin(float pX, float pY, float pWidth, float pHeight, TextureRegion pTextureRegion)
  6.                 {
  7.                         super(pX, pY, pWidth, pHeight, pTextureRegion);
  8.                         registerEntityModifier(new LoopEntityModifier(new ScaleModifier(1, 1f, 1.3f)));
  9.                 }      
  10.                
  11.                 @Override
  12.                 protected void onManagedUpdate(final float pSecondsElapsed)
  13.                 {              
  14.                         runOnUpdateThread(new Runnable()
  15.                         {
  16.                                 @Override
  17.                                 public void run()
  18.                                 {
  19.                                         if (face.collidesWith(Coin.this) && Coin.this.collidesWith(face) && !received)
  20.                                         {
  21.                                                 scene.detachChild(Coin.this);
  22.                                                 GameManager.playSound(coinPickSound);
  23.                                                 received = true;
  24.                                                 addToScore(10);
  25.                                         }
  26.                                 }
  27.                         });
  28.                         super.onManagedUpdate(pSecondsElapsed);
  29.                 }
  30.         }
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


But while using sprite batch, nothing happens (no reaction for collisions, and modifier doesnt work aswell)

Help please!
User avatar
Mathew
 
Posts: 1073
Joined: Sun Jul 31, 2011 2:49 pm
Location: Tarnów, Poland

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Zappescu » Thu Nov 17, 2011 11:49 am

Do someone could tell me if this SpriteBatch methodology could be used to improve classical AnimatedSprite animations FPS?
As of today, I create a TiledTextureRegion, I assigned it to an AnimatedSprite and when I need it I start it using myanimatedsprite.animate(100).
May I improve my approach using SpriteBatch or this is not my case?
Zapmobilegames website
Zapmobilegames
Facebook Tic Tank Toe Fans
Tic Tank Toe | Facebook
Tic Tank Toe: a new approach for a classical Game
Image
Zappescu
 
Posts: 105
Joined: Tue May 03, 2011 5:49 pm

Re: SpriteBatch -> 2x performance improvement anyone?

Postby Nicolas Gramlich » Sun Nov 27, 2011 11:53 pm

Hi,

Zappescu wrote:Do someone could tell me if this SpriteBatch methodology could be used to improve classical AnimatedSprite animations FPS?
As of today, I create a TiledTextureRegion, I assigned it to an AnimatedSprite and when I need it I start it using myanimatedsprite.animate(100).
May I improve my approach using SpriteBatch or this is not my case?


You cannot tell that for sure upfront, but it is worth a try (SpriteGroup btw instead of SpriteBatch, because SpriteBatch won't update each frame). The more sprites you have, the better.

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

Re: SpriteBatch -> 2x performance improvement anyone?

Postby drderico » Thu Dec 01, 2011 5:17 pm

drderico
 
Posts: 52
Joined: Tue Sep 28, 2010 8:54 pm
Location: Russia

Re: SpriteBatch -> 2x performance improvement anyone?

Postby bmfs » Mon Dec 05, 2011 12:15 am

Should we also use SpriteBatch if we have multiple sprites which are static but have different Textures?
bmfs
 
Posts: 12
Joined: Mon Jan 10, 2011 1:34 pm

PreviousNext

Return to Updates

Who is online

Users browsing this forum: No registered users and 3 guests