Inherit Problem
-
Hello Folks,
i have a problem with extending FlxObject (FlxSprite).
I try to add a callback to a tile. I use the setTileProperties and I'm trying to add a callback function. As the second parameter I have the class Player which extends from FlxSprite. But it says, that it has to be FlxObject. But FlxSprite extends FlxObject.
private function initMap():Void { map = new FlxOgmoLoader(AssetPaths.Map__oel); mWalls = map.loadTilemap(AssetPaths.Tileset__png, 32, 32, "floorAndWalls"); mWalls.follow(); var i:Int; for(i in 0...80) { mWalls.setTileProperties(i, FlxObject.NONE); } mWalls.setTileProperties(1, FlxObject.ANY, test, player); mWalls.setTileProperties(2, FlxObject.ANY); } private function test(tile:FlxObject, player:Player):Void { trace("Hello world!"); }
Fehler:
source/PlayState.hx:37: characters 45-49 : tile : flixel.FlxObject -> player : Player -> Void should be Null<flixel.FlxObject -> flixel.FlxObject -> Void>
source/PlayState.hx:37: characters 45-49 : tile : flixel.FlxObject -> player : Player -> Void should be flixel.FlxObject -> flixel.FlxObject -> Void
source/PlayState.hx:37: characters 45-49 : Cannot unify argument 2
source/PlayState.hx:37: characters 45-49 : flixel.FlxObject should be Player
source/PlayState.hx:37: characters 45-49 : For optional function argument 'Callback'Hope you can help me.
Thank you!
-