SHARE
TWEET

Obstacle

a guest Sep 24th, 2012 38 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. I'm using the Flixel port for Haxe NME. I'm having an issue with getting a collision callback function to work properly.
  3.  
  4. 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).
  5.  
  6. So I tried changing the first parameter in the callback to be of type Obstacle, and I get a strange error message (see below).
  7.      
  8. In my main class, TopDownLevel, I have...
  9. */
  10.  
  11. /**
  12. * Update each timestep
  13. */
  14. override public function update():Void
  15. {
  16.     super.update();
  17.     FlxG.collide(obstaclesGroup, player, obstacleTalk); // This is on line 259
  18. }//
  19.      
  20. /**
  21. * Talk to Obstacle/NPC
  22. */
  23. private function obstacleTalk(obstacle:Obstacle, plyr:FlxObject):Void
  24. {
  25.     FlxG.log("message: "+obstacle.message);
  26.     if(obstacle.message != "")
  27.     {
  28.         PlayState.chatWindow(obstacle.message);
  29.     }
  30. }//
  31.      
  32. /*
  33. However, I cannot compile. I get this error in the terminal:
  34.      
  35. Source/TopDownLevel.hx:259: characters 2-52 : ?obstacle : Obstacle -> ?plyr : org.flixel.FlxObject -> Void should be Null<org.flixel.FlxObject -> org.flixel.FlxObject -> Void>
  36. Source/TopDownLevel.hx:259: characters 2-52 : ?obstacle : Obstacle -> ?plyr : org.flixel.FlxObject -> Void should be org.flixel.FlxObject -> org.flixel.FlxObject -> Void
  37. Source/TopDownLevel.hx:259: characters 2-52 : org.flixel.FlxObject should be Obstacle
  38. Source/TopDownLevel.hx:259: characters 2-52 : For optional function argument 'NotifyCallback'
  39. */
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. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top