DrawImage coordinates Issue
Monkey Targets Forums/HTML5/DrawImage coordinates Issue
| ||
| I am loading an image and using the SetHandle() to set the image x and y coodinates. When I execute the DrawImage command I read the HandleX() and HandleY() it is not drawing the image at the correct x and y. What am I doing wrong? I tried fixed values but it is not working either.
Strict
Import mojo
Const APP_INF :Int= 1
Const APP_START :Int= 2
Class main Extends App
Field screenW:Float = 0
Field screenH:Float = 0
Field info_img:Image
Method OnCreate:Int()
SetUpdateRate(60)
screenW = 640.0
screenH = 480.0
loadImages()
astate = APP_START
Print "info W:"+info_img.Width()+" info H:"+info_img.Height()
Print "ScreenW:"+screenW + " screenH:" + (screenH-(info_img.Height()))
info_img.SetHandle(info_img.Width()/2,(screenH-info_img.Height()))
Print "hx:"+info_img.HandleX()+" hy:"+info_img.HandleY()
End
Method OnUpdate:Int()
'Print ("W:"+info_img.Width()+" H:"+info_img.Height())
'Print ("SetHandle:"+(screenH-info_img.Height()))
'Print ("ScreenW:"+screenW)
'Print ("ScreenH:"+screenH)
Return true
End
Method OnRender:Int()
Cls
DrawImage(info_img,info_img.HandleX(),info_img.HandleY())
DrawImage(info_img,450.0,450.0)
'Print "x:" + info_img.HandleX() + " y:" + info_img.HandleY()
DrawText "MouseX=" + MouseX() + ", MouseY="+ MouseY(),100,200
SetColor(255,242,0)
DrawCircle MouseX(), MouseY(),5
End
Method loadImages:Int()
info_img = LoadImage ("images/info.png")
Return True
End
End
Function Main:Int()
New main()
Return true
End
|
| ||
| Team never mind. The SetHandle() set's the image offset. After I comment it out it worked fine! |