Here's an example..
I need to have the mouse coordinates callable from e.g, the windows, in the gui's window lists. How is that done? I thought it was supposed to work when I did it this way. The mouse is just a child, it's not extended from gui, so why can't I do mouse.x etc. inside a method of a gui-extend?
Strict Graphics 800,600,0,60 Global gui:tgui = New tgui gui.windowlist.addlast(twindow.create()) Repeat gui.draw() Flip;Cls Until KeyHit(key_escape) Type tgui Field x,y Field mouse:tmouse = New tmouse Field windowlist:TList = CreateList() Method draw() mouse.update() mouse.draw() For Local window:twindow = EachIn windowlist window.draw() window.checkcollide() Next EndMethod EndType Type tmouse Field x,y Method update() x = MouseX() y = MouseY() EndMethod Method draw() DrawOval x,y,60,60 EndMethod EndType Type twindow Extends tgui Field x,y,w,h Method checkcollide() 'here's the problem, how can I make it so twindow can see gui.mouse? If mouse.x > 0 And mouse.y > 0 If mouse.x > x And mouse.x < x+w And mouse.y > y And mouse.y < y+h w = 200 Else w = 100 EndIf EndIf EndMethod Method draw() DrawRect x,y,w,h EndMethod Function create:twindow(x=200,y=300,w=100,h=100) Local window:twindow = New twindow window.x = x ; window.y = y window.w = w ; window.h = h Return window:twindow EndFunction EndType
I need to have the mouse coordinates callable from e.g, the windows, in the gui's window lists. How is that done? I thought it was supposed to work when I did it this way. The mouse is just a child, it's not extended from gui, so why can't I do mouse.x etc. inside a method of a gui-extend?