Invalid Image Frame - graphics.monkey

Monkey Forums/Monkey Programming/Invalid Image Frame - graphics.monkey

Amon(Posted 2013) [#1]
Function DrawImage( image:Image,x#,y#,rotation#,scaleX#,scaleY#,frame=0 )

#If CONFIG="debug"
	DebugRenderDevice
	If frame<0 Or frame>=image.frames.Length Error "Invalid image frame"
#End


I have no idea why this is happening. The image is a strip of tiles 64x448. Loadimage contains the amount of frames (7) and when drawing the tiles I use the (6) to represent the last tile in the image strip.

This only happens every now and again. I don't know why.



[edit]

It seems to be a problem with diddy specifically when using its built in Tiled loading routines. If I have in my GameScreen "diddyGame.images.Find("tiles")" then when a level is complete and I fade quickly to a "levelcomplete screen", up my LevelID then fade back to the GameScreen to load a new map from Tiled it then borks but only if I have in 'start' "diddyGame.images.Find("tiles")".

If I set a flag so that no matter how many times the GameScreen is reloaded it doesn't execute "diddyGame.images.Find("tiles")" again everything seems to work fine.

Again, I know I may have posted my error too early but at least this way I can hunt down what's causing this and if diddy is not the problem I will retract when I have further updates.


Amon(Posted 2013) [#2]
It seems to be a problem with diddy specifically when using its built in Tiled loading routines. If I have in my GameScreen "diddyGame.images.Find("tiles")" then when a level is complete and I fade quickly to a "levelcomplete screen", up my LevelID then fade back to the GameScreen to load a new map from Tiled it then borks but only if I have in 'start' "diddyGame.images.Find("tiles")".

If I set a flag so that no matter how many times the GameScreen is reloaded it doesn't execute "diddyGame.images.Find("tiles")" again everything seems to work fine.

Again, I know I may have posted my error too early but at least this way I can hunt down what's causing this and if diddy is not the problem I will retract when I have further updates.


Amon(Posted 2013) [#3]
I think I narrowed it down to a similar problem I was having with Diddy ages ago with the images.Load/LoadAnim commands.

Basically if you used the normal method of loading an image in the LoadImages part before newing screens; trying to load the image again for the tilemap would cause a similar crash.

So whatever was done by therevills for the Load/LoadAnim commands the same needs doing for the .Find commands.

Hope that helps.