Collision broken with flxSpriteGroup

205 views
Skip to first unread message

Laguna

unread,
Aug 25, 2015, 9:55:42 AM8/25/15
to HaxeFlixel
Hi there,

with my last Haxeflixel project I stumbled upon a strange haxeflixel "occurrence" (probably bug?). 
Collision seems to be broken when using a FlxSpriteGroup when the collisions happen at a coordinate larger than FlxG.width or height.

Appended to this post is a minimal working example that shows the problem. There is a player class, as well as a tile class, both flxSprites. Tiles are randomly spawned in the world.
The collision works fine if the player's position is within the FlxG.width / FlxG.height. (try this by walking left in the example)
If The position is outside this rect, collisions are just ignored and the player can just pass through any tile. (try this by walking right in the example)

The problem occurrs with FlxSpriteGroup as well as with FlxTypedGroup<Tile>. It also occurs on flash, neko and windows as  build targets.

"NOTE: Although FlxGroup extends FlxBasic, it will not automatically add itself to the global collisions quad tree, it will only add its members."

I would be very glad if someone else could reproduce this or even better: A fix for this problem.
If you are tempted to ask why I am not using a FlxTileMap: They are kind of limiting, since I want to do more stuff with my tiles.


Best regards,
Laguna


My list of installed haxelibs
actuate: [1.8.6]
box2d: [1.2.3]
flixel-addons: [1.1.0]
flixel-demos: [1.1.2]
flixel-templates: [1.0.2]
flixel-tools: [1.1.1]
flixel-ui: [1.0.2]
flixel: [3.3.11]
hxcpp: [3.2.102]
layout: [1.2.1]
lime-samples: 2.5.1 [2.6.0]
lime: 2.5.3 [2.6.0]
openfl-samples: [3.1.0]
openfl: 3.3.0 [3.3.1]
swf: [1.9.1]
CollisionTester.zip

SruloArt

unread,
Aug 25, 2015, 10:30:05 AM8/25/15
to HaxeFlixel
* Can't test, but have you checked your worldBounds?

Laguna

unread,
Aug 25, 2015, 10:56:26 AM8/25/15
to haxef...@googlegroups.com
Hi there, 

thank you for your help, setting the worldbounds to the correct values fixes the problem. I did not know there was such a member and that it hat to be set. It would probably be a good idea to change the documentation of FlxCollide and/or FlxOverlap so this is represented online.

Best regards,
Laguna

Xavier Belanche

unread,
Aug 26, 2015, 4:57:31 PM8/26/15
to HaxeFlixel
Hi

Well actually I have a similar issue. Working on a simple flipped room platform I found this "bug"? As you can see, the collision between player with tiles works well except that annoying case that player can walk through tile (only that one!) I'd appreciate some help, clue or suggestion to figure out what type of mistake I'm doing.

SruloArt

unread,
Aug 27, 2015, 4:08:08 AM8/27/15
to HaxeFlixel
* If you're working on dev it might be wise to update your libraries.
* Also, you should collide the level with the player and not the other way around.

Laguna

unread,
Aug 27, 2015, 4:27:33 AM8/27/15
to HaxeFlixel
Hi there, 
did you check, that your origin and offset values are correct (for flipping) and that you called FlxSprite.updateHitbox() if you use scale and/or rotate?

Best regards,
Laguna

Xavier Belanche

unread,
Aug 29, 2015, 11:01:48 AM8/29/15
to HaxeFlixel
Thanks for your help!

I udated the dev libraries but now I got an error (using dev git):

C:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:32: characters 4-31 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_DARKEN (Suggestions: TILE_BLEND_SCREEN, TILE_BLEND_NORMAL)
C
:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:34: characters 4-32 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_LIGHTEN (Suggestion: TILE_BLEND_SCREEN)
C
:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:36: characters 4-32 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_OVERLAY (Suggestion: TILE_BLEND_NORMAL)
C
:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:38: characters 4-34 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_HARDLIGHT
C
:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:40: characters 4-35 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_DIFFERENCE
C
:/HaxeToolkit/haxe/lib/flixel/git/flixel/graphics/tile/FlxDrawBaseItem.hx:42: characters 4-31 : Class<openfl._legacy.display.Tilesheet> has no field TILE_BLEND_INVERT (Suggestion: TILE_BLEND_SCREEN)

I'll notify later... btw I'l check everything you told me before I move to recreate this issue creating a simple and clean demo. Sure it's my bad and ugly code!

Best,

Xavier Belanche

unread,
Aug 29, 2015, 6:12:37 PM8/29/15
to haxef...@googlegroups.com
Hey

I made a simple demo when you can see the collsion issue in action:


I upload the source code to github (could be helpful to others I guess): 


The annoying issue:


Libraries:



λ haxelib list

actuate
: 1.8.2 1.8.4 1.8.5 [1.8.6]
box2d
: [1.2.3]
flixel
-addons: git [dev:C:\HaxeToolkit\haxe\lib\flixel-addons/git]
flixel
-demos: git [dev:C:\HaxeToolkit\haxe\lib\flixel-demos/git]
flixel
-templates: git [dev:C:\HaxeToolkit\haxe\lib\flixel-templates/git]
flixel
-tools: git [dev:C:\HaxeToolkit\haxe\lib\flixel-tools/git]
flixel
-ui: git [dev:C:\HaxeToolkit\haxe\lib\flixel-ui/git]
flixel
: git [dev:C:\HaxeToolkit\haxe\lib\flixel/git]
hxcpp
: 3.1.68 [3.2.102] 3.2.81 3.2.94
layout
: 1.2.0 [1.2.1]
lime
: 2.1.2 2.3.3 2.4.1 2.4.4 2.4.8 2.4.9 2.5.2 2.5.3 [2.6.1]
nape
: [2.0.19]
openfl
-samples: 2.2.2 3.1.0 [3.3.0]
openfl
-webm: [0.0.4]
openfl
: 2.2.7 3.0.3 3.0.6 3.1.0 3.1.1 3.1.2 3.1.3 3.2.2 3.3.0 [3.3.2]
polygonal
-ds: [1.4.1]
polygonal
-printf: [1.0.2-beta]
swf
: 1.7.7 1.8.6 1.8.7 1.8.8 1.8.9 1.9.1 [2.0.1]



and today I checked "haxelib upgrade".


Thanks in advance!

SruloArt

unread,
Aug 29, 2015, 7:03:50 PM8/29/15
to HaxeFlixel
* Try uploading a debug project, this doesn't help too much.
* Maybe your sprite's hitbox is too small or you're adding the collide code before you call super.update...
* And I would bet it's something to do with your camera as well, so, plenty of stuff going on here.
...

Xavier Belanche

unread,
Aug 29, 2015, 8:11:34 PM8/29/15
to HaxeFlixel
* Oh sorry man: here it is: http://www.fastswf.com/fos2PWE (press D key to display debugger console instead of ~)
* I changed and put super,update before and after of collide code and nothing changes 
* Same too. I don't like how it works the camera here :-/ If you plus 64 to the last height paramater it solves the collide issue!

82c82
<                       FlxG.height,
---
>                       FlxG.height + 64,

Xavier Belanche

unread,
Aug 29, 2015, 11:30:06 PM8/29/15
to HaxeFlixel
Solved!


It was my mistake. I was very confused with camera methods setScrollBoundsRect and setScrollBounds... (but not now! lesson learned!)

I committed the changes to the repo if anyone want to know how it works.

Thanks SruloArt for your help!
Reply all
Reply to author
Forward
0 new messages