FlxSpriteGroup collision as a single object

102 views
Skip to first unread message

Emanuele

unread,
Nov 9, 2015, 5:47:36 PM11/9/15
to HaxeFlixel
The main character of my game is a FlxSpriteGroup where every sprite inside is a different body part ( head, legs, body, etc.)
I'm trying to make the character collide together with another walls FlxGroup wich contains the edges of the screen, but the problem is that the FlxG.collide function is colliding each of the sprites inside the FlxSpriteGroup on its own, so when walking in a wall the various body parts get clumped together.

What I'd like to do is have a hitbox on the feet of the character and use that for the collision of the whole SpriteGroup, but I haven't found a way to do this.

Any help?

SruloArt

unread,
Nov 10, 2015, 3:31:09 AM11/10/15
to HaxeFlixel
* FlxNestedSprite (it's in the addons repo) is a better choice.

* But your solution is simple: add to your group a FlxObject with a proper size and make it the only member to have collisions. 

Emanuele

unread,
Nov 10, 2015, 10:08:59 AM11/10/15
to haxef...@googlegroups.com
I tried using the FlxNestedSprite as you suggested but got 2 problems:

A small haxe icon appears at the top left of the sprite, and changing the x and y position of the sprites inside it doesn't seem to move them.

EDIT: Fixed it, Thank you!
Reply all
Reply to author
Forward
0 new messages