I want the player to pickup objects in my game using the code below, but I am getting:
Error #1034: Type Coercion failed: cannot convert flixel::FlxSprite@51e1b69 to Player.
...
FlxG.overlap(weapons, players, onPickup)
}
private function onPickup(wep:Weapon, player:Player):Void
{
//access player function
}
I've initialized the players and weapons already as below, and added to the group
players= new FlxTypedGroup<Player>();
weapons= new FlxTypedGroup<Weapon>();
Weapon
extends FlxSprite
and Player
extends FlxTypedGroup<FlxSprite>
.
I'm using FlxTypedGroup
because I want the player to have multiple sprites associated with it.
Please help so I can access the player class variables!
If I replace player:Player
with player:FlxSprite
there is no error, but then I can no longer access Player
class functions.