Images get deleted by LoadImage?

Monkey Forums/Monkey Programming/Images get deleted by LoadImage?

zardon(Posted 2013) [#1]
Hello there.

I am currently learning Monkey and am following a tutorial I found. I am putting an image inside the `MyProject.build > html5 > data` folder but when I run my code it deletes the image but I don't know why or how to prevent this from happening.

The code I am using now follows;

Import mojo

' Required my Monkey
Function Main()
	New Game
End

Class Game Extends App
	
	Field player:Image
	Field x:Float
	Field y:Float
	
	Method OnCreate()
		player = LoadImage("boing.png")
	End
	
	Method OnUpdate()
		If KeyDown(KEY_LEFT) Then x=x-4
		If KeyDown(KEY_RIGHT) Then x=x+4
		If KeyDown(KEY_UP) Then y=y-4
		If KeyDown(KEY_DOWN) Then y=y+4
	End 
	
	Method OnRender()
		Cls	64,96,128
		DrawImage player,x,y
	
	End
	
	
End



Supertino(Posted 2013) [#2]
is the image in your top level /data folder? the compile will copy the image from that to your builds /data folder for you.


ElectricBoogaloo(Posted 2013) [#3]
You're meant to put the image into MyGame.data/ folder.
Then, whenever you hit F5 to compile, everything gets copied from there, into MyGame.build/html5/data.
Basically, that folder is a clone of the MyGame.data/ folder, so that any changes you make to that single folder, are replicated for all other targets.
It gets a little bit messy, having loads of cloned data, but what the heck. It's worth it!