How to draw only a part of a Sprite?

  ... discussions about development with the GLES1 branch of AndEngine.

How to draw only a part of a Sprite?

Postby giannign1 » Sun Nov 06, 2011 4:08 am

Hi
for example i have a Sprite 30x30 at (20,20) declared like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Sprite sp = new Sprite(20,20,30,30,mRegion);
  2.  
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


I need that that Sprite will be drawen only for the inferior half part, so from its local coordinates (0,15) for the size 30x15

How can i do that??

Thank you

Gianni
giannign1
 
Posts: 16
Joined: Fri Sep 30, 2011 4:14 pm

Re: How to draw only a part of a Sprite?

Postby bogdan_tmm » Mon Nov 07, 2011 9:28 am

Modify your picture :P
bogdan_tmm
 
Posts: 107
Joined: Wed Jul 27, 2011 3:48 pm

Re: How to draw only a part of a Sprite?

Postby MisterD » Mon Nov 07, 2011 4:23 pm

giannign1 wrote:Hi
for example i have a Sprite 30x30 at (20,20) declared like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Sprite sp = new Sprite(20,20,30,30,mRegion);
  2.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


I need that that Sprite will be drawen only for the inferior half part, so from its local coordinates (0,15) for the size 30x15

How can i do that??

Thank you

Gianni


Not 100% sure I understood your question but to modify the sprite size by clipping try;

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. mRegion.setWidth(30);
  2. mRegion.setHeight(15);
  3. mRegion.setTexturePosition(0, 15);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Or use an animated sprite with 2 frames, 30x15 pixels each, and manually set the frame number.
MisterD
 
Posts: 4
Joined: Tue Nov 01, 2011 9:46 am


Return to GLES1

Who is online

Users browsing this forum: No registered users and 14 guests