AramCP Posted November 23, 2016 Share Posted November 23, 2016 Hi guys i just wanted to know if i can set something like a collision area in a sprite. I need to do that because i have a player sprite, who colides with trees and other stuff, i'll post images to make it more simple to understand. Okay this is my game: http://prntscr.com/dasmyg The player is suposed to collide with the tree's log, but when i come near to the tree, the collision is more like that: http://prntscr.com/dasns6 Thats because my sprite is 16x32, well he is only 19 pixels height, the rest its transparent, but its still there so its detected like a collision. Maybe you will say me i have to resize the sprite to be only 19 pixels height, but then it will look like this: http://prntscr.com/dasp2e And i want him to look like this: http://prntscr.com/daspb5 I want him to touch the tree with his head. So, is there a way to do that? PD: I edited the last photo to make the overlay Link to comment Share on other sites More sharing options...
The_dude8080 Posted November 23, 2016 Share Posted November 23, 2016 Why don't you resize the log area? Link to comment Share on other sites More sharing options...
LuizOtavio Posted November 23, 2016 Share Posted November 23, 2016 hi @AramCP, i guess, you looking for Offset Bounding Box check out this example https://phaser.io/examples/v2/arcade-physics/offset-bounding-box cheers samme, AramCP and WombatTurkey 3 Link to comment Share on other sites More sharing options...
Zendrael Posted November 25, 2016 Share Posted November 25, 2016 Hi! If you are using ArcadePhysics you can use the code YourSprite.body.setSize(width, height, XinSprite, YinSprite); It will create a collidable area inside your sprite. FranXtrada and AramCP 2 Link to comment Share on other sites More sharing options...
Recommended Posts