SHARE
TWEET
Obstacle
a guest
Sep 24th, 2012
38
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- /*
- I'm using the Flixel port for Haxe NME. I'm having an issue with getting a collision callback function to work properly.
- I have an Obstacle class that extends FlxSprite. Inside this class is a String called "message", and it's public. My callback function, obstacleTalk, originally accepted just two FlxObjects, and I referenced the "message" variable in the relevant FlxObject for the Obstacle. But this gave me an error that said "message" didn't exist in FlxObject (obviously).
- So I tried changing the first parameter in the callback to be of type Obstacle, and I get a strange error message (see below).
- In my main class, TopDownLevel, I have...
- */
- /**
- * Update each timestep
- */
- override public function update():Void
- {
- super.update();
- FlxG.collide(obstaclesGroup, player, obstacleTalk); // This is on line 259
- }//
- /**
- * Talk to Obstacle/NPC
- */
- private function obstacleTalk(obstacle:Obstacle, plyr:FlxObject):Void
- {
- FlxG.log("message: "+obstacle.message);
- if(obstacle.message != "")
- {
- PlayState.chatWindow(obstacle.message);
- }
- }//
- /*
- However, I cannot compile. I get this error in the terminal:
- Source/TopDownLevel.hx:259: characters 2-52 : ?obstacle : Obstacle -> ?plyr : org.flixel.FlxObject -> Void should be Null<org.flixel.FlxObject -> org.flixel.FlxObject -> Void>
- Source/TopDownLevel.hx:259: characters 2-52 : ?obstacle : Obstacle -> ?plyr : org.flixel.FlxObject -> Void should be org.flixel.FlxObject -> org.flixel.FlxObject -> Void
- Source/TopDownLevel.hx:259: characters 2-52 : org.flixel.FlxObject should be Obstacle
- Source/TopDownLevel.hx:259: characters 2-52 : For optional function argument 'NotifyCallback'
- */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
