Batzi Posted September 24, 2015 Share Posted September 24, 2015 Hello I am new to Phaser and decided to follow a tutorial on how to create a Space Invaders clone. The tutorial was cut short so I had to continue myself. I am having problems with some of my sprites. They're all PNG having transparent backgrounds but when I did a debugging to see how the collision was working I realized that they were surrounded by an invisible box that was affecting the way I wanted the sprites to collide. Here's an example of what is going on As you can see, the bullet itself is taking so much space and that makes it a big problem since I want it to collide with the alien sprite. Any reason why this might be happening? Thank you Link to comment Share on other sites More sharing options...
rich Posted September 25, 2015 Share Posted September 25, 2015 The body size (the green rectangles in the shot above) is set based on the image size. So if your bullet has lots of transparent pixels around it then you'll get a larger than needed body. You've two choices: 1) Trim your images to remove the empty space, or 2) Change the body size. There is an example on how to set the body size. Batzi and jdnichollsc 2 Link to comment Share on other sites More sharing options...
Batzi Posted September 25, 2015 Author Share Posted September 25, 2015 The body size (the green rectangles in the shot above) is set based on the image size. So if your bullet has lots of transparent pixels around it then you'll get a larger than needed body. You've two choices: 1) Trim your images to remove the empty space, or 2) Change the body size. There is an example on how to set the body size.Thank you for your reply. I will try that and will get back to you. Link to comment Share on other sites More sharing options...
Recommended Posts