Passing objects

BlitzMax Forums/BlitzMax Beginners Area/Passing objects

Ant(Posted 2005) [#1]
Hi - I continue my scary journey into OOP! I'm trying to pass an object (an instance of a type if I understand it correctly) to a method. I'm then assigning that instance to another instance (if you are following this) within the ProcessButtons Method. However, when I debugstop after the currentScreen=Button.TargetScreen, the currentScreen=NULL which is obviously causing an error.

The code is below, is there a particular way to assign currentScreen another Type?

Essentially I want the player to click on a button, and depending on the button clicked will change the screen that is drawn (referenced by currentScreen). Thanks for any help as always.




Ant(Posted 2005) [#2]
Ok the problem lies within the addbutton method. When I pass an object to it, the object passed is NULL. Still dont understand why though


Who was John Galt?(Posted 2005) [#3]
MainMenu.AddButton("Help", 100,200, "click.png", STATIC,HelpScreen)

This line comes before HelpScreen has been created - i.e: HelpScreen=NULL will be passed to the function.


Ant(Posted 2005) [#4]
D'oh. How embarrassing! Thanks!


Who was John Galt?(Posted 2005) [#5]
Nah happens to everyone