1
Graphics / Draw a sprite at the bottom of screen, using its own size
« on: March 02, 2021, 10:03:18 pm »
Hi guys
This is whats happening:
1. I have a spritesheet image with some textures from various elements.
2. I created a sprite based on a this spritesheet, defining the texture rect.
3. I also resized the sprite down according by ratio of the screen width.
The sprite is drawn perfectally, no problems there.
Now I want to align the sprite to the bottom of the screen,so I set its position like this:
midGroupSky2Sprite.setPosition(1, window.getSize().y -midGroupSky2Sprite.getGlobalBounds().height);
The result makes part of the sprite go offscreen at the bottom and not perfectally aligned.
I then tried this:
midGroupSky2Sprite.setPosition(1, window.getSize().y - midGroupSky2Sprite.getTextureRect().height);
The sprite is now too high.
What am I doing wrong ?
This is whats happening:
1. I have a spritesheet image with some textures from various elements.
2. I created a sprite based on a this spritesheet, defining the texture rect.
3. I also resized the sprite down according by ratio of the screen width.
The sprite is drawn perfectally, no problems there.
Now I want to align the sprite to the bottom of the screen,so I set its position like this:
midGroupSky2Sprite.setPosition(1, window.getSize().y -midGroupSky2Sprite.getGlobalBounds().height);
The result makes part of the sprite go offscreen at the bottom and not perfectally aligned.
I then tried this:
midGroupSky2Sprite.setPosition(1, window.getSize().y - midGroupSky2Sprite.getTextureRect().height);
The sprite is now too high.
What am I doing wrong ?