just started and already something ive done before giving me problems arghhh.
the mouse over is not functioning right it changes press frame on coords i didnt give it i dont understand.
in the mainscreen class under update please help.
strict
Import mojo
Class mouse
Field image:Image
Method New()
image = LoadImage("PNG/UI/cursor.png")
End
Method Draw:Int()
DrawImage(image,MouseX(),MouseY())
Return 0
End
End
Class MainScreen
Field image:Image
Field Sbutton:Image
Field Obutton:Image
Field SbuttX:Int = screenWidth/2
Field SbuttY:Int = screenHeight/2
Field ObuttX:Int = screenWidth/2
Field ObuttY:Int = screenHeight/2
Field Oframe:Int = 1
Field Sframe:Int = 1
Method New()
image = LoadImage("background1.png")
Sbutton = LoadImage("PNG/UI/start.png",380/2,49,2,Image.MidHandle)
Obutton = LoadImage("PNG/UI/options.png",380/2,49,2,Image.MidHandle)
End
Method Update:Int()
If MouseX() <= SbuttX - 95 or MouseX() >= SbuttX + 95 And MouseY() <= SbuttY - 24 Or MouseY() >= SbuttY + 24
Sframe = 0
Else
Sframe = 1
End
Return 0
End
Method Draw:Int()
DrawImage(image,0,0)
SetAlpha .9
DrawImage(Sbutton,SbuttX,SbuttY+ 40,Sframe)
DrawImage(Obutton,ObuttX,ObuttY+100,Oframe)
Return 0
End
End
Const screenWidth:Int = 640
Const screenHeight:Int = 480
Class spacegame Extends App
Field mainScreen:Int = 1
Field options:Int = 2
Field selectScreen:Int = 3
Field gameOn:Int = 4
Field gameOver:Int = 5
Field gameState:int
'CLASSES
Field splash:MainScreen
Field pointer:mouse
Method OnCreate:Int()
SetUpdateRate(60)
'HideMouse()
gameState = mainScreen
splash = New MainScreen
pointer = New mouse
Return 0
End
Method OnUpdate:Int()
Select gameState
Case mainScreen
splash.Update()
Case options
Case selectScreen
Case gameOn
Case gameOver
End
Return 0
End
Method OnRender:Int()
Cls(0,0,0)
Select gameState
Case mainScreen
splash.Draw()
pointer.Draw()
Case options
Case selectScreen
Case gameOn
Case gameOver
End
Return 0
End
End
Function Main:Int()
New spacegame()
Return 0
End
|