problem with image

Monkey Forums/Monkey Programming/problem with image

wiliamtn(Posted 2013) [#1]
hi everybody

Friends i need help with a little problem, when i try load and draw an image i always have an error of execution.
This is my monkey code:

Import mojo

Class Game Extends App

Field image:Image


Method OnCreate()
SetUpdateRate 30


image = LoadImage("cena/cenagame1.jpg")
End


Method OnRender()
Cls
DrawImage image,20,20
End


End


Function Main()
New Game()
End

and this is the message that monkey shows for me:

Monkey Runtime Error : Null object access

C:/Program Files/MonkeyPro63b/modules/mojo/graphics.monkey<491>
C:/Program Files/MonkeyPro63b/Game1/zumbiVSBebados.monkey<18>
C:/Program Files/MonkeyPro63b/modules/mojo/app.monkey<70>


Jesse(Posted 2013) [#2]
you need to create a folder with the name of the game with the "data" extension in the same folder where you have your game. in your case "game1":

zumbiVSBados.data



if you want the graphics in it's own folder than your graphics need to be in a folder "cena" like this:

ZumbiVSBados.data/cena




do this in the line below the load image to check if the image was loaded:
If image = null Error "Unable to load image"


this will check if the image was loaded and produce an error if not.


wiliamtn(Posted 2013) [#3]
Thank you Jesse