[Solved] Sprite is not shown after setScale()

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

[Solved] Sprite is not shown after setScale()

Postby bos » Tue Apr 03, 2012 2:43 pm

On a board-game I'm making I have one block (B1) in the top-left corner of the screen and one (B2) in top-right. B1 is 170 pixels wide, B2 is 128 pixels wide.

I need to scale B1 so its size is the same as B2. I tried this:

B1.setScaleCenter(0, 0);
B1.setScale(B2.getWidth() / B1.getWidth());

But doing this AndEngine will erase the B1-block completely. Doing the reciprocal, B1/B2, the sprite is shown but a bit larger.

What am I missing here?
Last edited by bos on Tue Apr 03, 2012 2:53 pm, edited 1 time in total.
bos
 
Posts: 44
Joined: Fri Jan 13, 2012 4:15 am

Re: Sprite is not shown after setScale()

Postby bos » Tue Apr 03, 2012 2:53 pm

It seems that Java made an integer division of that one, and that the result was 0. I.e. the sprite was shrunk to invisibility :-)

Solution: Explicit float-casting in front of both numbers solved it.
bos
 
Posts: 44
Joined: Fri Jan 13, 2012 4:15 am


Return to GLES1

Who is online

Users browsing this forum: No registered users and 22 guests