Jump to content

Weird thing happening with my sprites


Batzi
 Share

Recommended Posts

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

 

debug.png

 

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

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.

Link to comment
Share on other sites

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...