Spritebatch not anchor center sprites

  ... in the unlikely case you discovered a bug, post it here.

Spritebatch not anchor center sprites

Postby felipefcm » Mon Mar 31, 2014 7:04 am

Hello! I already posted a question about this in the GLES2 forum, but now I'm certain that this is a bug.

Previous post: gles2/spritebatch-not-anchorcenter-t16165.html

The image shows the same sprite drawn twice.
The centered one is attached to the scene, and the other is added in a Spritebatch using 'draw' method.

Image


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. float centerX = SCREEN_CENTER_X;
  2. float centerY = SCREEN_CENTER_Y;
  3.                
  4. final Sprite sprite = new Sprite(centerX, centerY, m_Region, mEngine.getVertexBufferObjectManager());
  5.  
  6. m_Batch.draw(sprite);
  7. m_Batch.submit();
  8.                
  9. m_Scene.attachChild(sprite);
  10. m_Scene.attachChild(m_Batch);
  11.  
Parsed in 0.011 seconds, using GeSHi 1.0.8.4


It becomes pretty clear that the offset is half sprite size, so Spritebatch does not anchor center it's sprites.
As I already mentioned in the other post, the workaround solution would be simple, just subtract from Spritebatch position this offset, but this has other side effects. For example if I wanted to receive touches in those sprites, the touch area would be displaced.

Spritebatch is really a cool feature that uses hardware more wisely and even in my case, where performance is not that critical, is good to know that stuff is being done efficiently.
felipefcm
 
Posts: 3
Joined: Fri Mar 28, 2014 6:37 am

Return to Bugs

Who is online

Users browsing this forum: No registered users and 2 guests