Image frame outside surface

Monkey Forums/Monkey Beginners/Image frame outside surface

Baxt3r(Posted 2015) [#1]
Hi Guys! im new to this amazing language, btw i have just see the courses from Smalltime Outlaws on You Tube, and now im on the video of loading images and im stuck here, cause when i try to draw the image say to me

"Image frame outside surface" and open the graphics file of mojo...

Why happend this? how can i fix?

Heres my code

Import mojo

Class MyGame Extends App

Field ship:Image
Field explosion:Image


Method OnCreate()
SetUpdateRate(60)

ship = LoadImage("ship.png",1, Image.MidHandle )
explosion = LoadImage("explosion.png", 32, 8, 4, Image.MidHandle)

End

Method OnUpdate()

End

Method OnRender()
Cls(125, 125, 255)
SetColor(255, 0, 0)

DrawImage(ship, 200, 200, 0)
End

Method OnLoading()

End

Method OnSuspend()

End

Method OnResume()

End
End

Function Main()
New MyGame()
End

Thank you!


Baxt3r(Posted 2015) [#2]
I solve it guys, thank you btw! was the frame size, i thinked was the total size of the img cause was multiple frame. Thank you!


Steve Ancell(Posted 2015) [#3]
If your images are on just one row, side by side, then try this. Divide the image width by 32, if the result is 4 then it should work. If you divide the width by 4 then you should get 32.


Steve Ancell(Posted 2015) [#4]
If you get more than 32 or 4 in either case then that explains the error.


Steve Ancell(Posted 2015) [#5]
I use GrabImage to cut up and put image frames into an array, but that's just my awkward preference, not everyone likes doing it the way I do it. I use this way so that I can have tiles and sprite frames of different sizes.