Trouble with Monkey Demo
Community Forums/Monkey Talk/Trouble with Monkey Demo
| ||
Hi So I thought I would try out monkey. I cant seem to get anywhere with it. It must be something simple but I've been over and over the tutorial code and can't work out what I am doing wrong. My first try was to put an image on the screen. The file is saved as greenhood.monkey so I put the image in a greenhood.data folder and ran my code. It said "Null Object Access" and was referring to the LoadImage line. So I tried commenting out the load Image and draw image and just display hello world. If failed with Cls saying that "Rendering operations can only be performed inside OnRender" .... which is where it is. My Code: [monkeycode] Strict Import Mojo Function Main:Int() New greenHood Return 0 end Class greenHood Extends App Field gameState:Int = 0 Field iIntroScreen:Image Method OnCreate:Int() iIntroScreen = LoadImage("TitleScreen.png") gameState = 0 SetUpdateRate( 30 ) Return 0 End Method OnUpdate:Int() Return 0 End Method OnRender:Int() Cls If gameState = 0 DrawText "Hello World",0,0 DrawImage(iIntroScreen, 0, 0) End Return 0 End End [/monkeycode] |
| ||
You have a lowercase end (at the end of your function) - i'm not very conversant with Monkey but as I recall, it's case sensitive. So maybe it should be End. |
| ||
Thanks, I just tried changing that, but still the same things happen. |
| ||
I found the problem, and it was a case sensitive thing, you have to Import mojo with a lowercase M |
| ||
where's the image file located? |