Hi all, having a braint twist with an OOP concept. Below I have declated a type TScreen and a method to create a screen. Within this type, I've also declared a list of buttons which I want to associate with this screen.
I think this is all pretty standard. However, I'm unsure once I've created this list of buttons of how to access them once they have been created. How would I go about assigning fields to the first button and how would I know if a button already exists?
Thanks
I think this is all pretty standard. However, I'm unsure once I've created this list of buttons of how to access them once they have been created. How would I go about assigning fields to the first button and how would I know if a button already exists?
Thanks
Type TScreen Field sName:String Field background:TImage ' Create a list of buttons belonging to the screen Field buttons:Tlist = New Tlist 'Creates a list of screens Global ScreenList: TList Function UICreateScreen:TScreen(name:String, image:String, totalButtons:Int) Local NewScreen: TScreen NewScreen = New TScreen NewScreen.sName = name$ NewScreen.background = LoadImage(image$) ' Verfiy files exist and are of correct size Assert NewScreen.background Else "Cannot find file '"+image$+ "'." Assert NewScreen.background.width=iScreenWidth Else "Background: "+image$+" size does Not match screen width." Assert NewScreen.background.height=iScreenHeight Else "Background: "+image$+" size does Not match screen height." If Not screenlist Then ScreenList:Tlist = CreateList() ' Once all checks are done add screen to list ScreenList.addlast ( NewScreen) 'Create a list of buttons which will be a part of this screen For Local temp=1 To totalButtons NewScreen.buttons.addlast( New TButton) Next 'This should return the object just created so we can access it at a later date Return NewScreen EndFunction EndType Type TButton Field sName:String Field x:Int Field y:Int Field normal:TImage Field link:Int Field iCellWidth:Int=169 Field iCellHeight:Int=75 Field iTotalFrames:Int=0 endtype Global MainMenu: TScreen MainMenu=TScreen.UICreateScreen("MainMenu","background.png",5)