Can't See Bullets
So I just picked up HaxeFlixel this weekend and am trying to make a sort of top down shooter similar to Binding of Isaac. Currently I am trying to get the player bullets working but although they collide with the world properly, they are never visible. I have a feeling it has to do with how I am using FlxTypedGroup. As you can see from my code, I went through all but the combat portion of the RPG tutorial found on this website so perhaps that could be causing a problem as well. All the relevant code is on PlayState.hx and the Bullet.hx.
First off, you need to
add()the bullet group to the state. That call is already there, but commented out, so I guess you experimented around with that.
The main issue is that the
bulletHitMapcallback triggers immediately. The reason for this is described in the docs for
NOTE: this takes the entire area of FlxTilemaps into account (including "empty" tiles). Use FlxTilemap#overlaps() if you don't want that.
In this case, you can just replace the call with
FlxG.collide(_grpBullets, _mWalls, bulletHitMap);
Some other things to note regarding recycling:
You don't need to initialize
recycle()automatically creates instances.
For recycled objects, the initialization logic is typically put into a separate
init()method, not the constructor. This way, you can call
var bullet = _grpBullets.recycle(Bullet); bullet.init(_player);
@Gama11 Great that did it! Thank you for the quick and thorough response.