Wrong image sometimes showingMonkey Programming Forums/Monkey Programming/Wrong image sometimes showing
| Not sure if I've uncovered a bug or if it's a strange error in my code, but I'm having this occasional problem. Very occasionally, the wrong image is being shown when I use the DrawImage command. At first I thought it was an error in my code, because it seemed to be the same graphic each time, but now it's started happening on another image. The reason I think it might be a bug in Monkey, is because my images are directly referenced, e.g my 'Game Over' text is just a small graphic I made for that purpose, and to print it I just use 'DrawImage GameOver,X,Y', where 'GameOver' is also the name of the image. I don't see how, in that case, it could possibly be a bug in my code, since the image which sometimes shows through instead is a totally different image with a different name. If I was using arrays of images or something, I'd suspect an error in my code, but it seems impossible in this case.|
I can't think of a good way of showing this in an example, but I'll try if necessary. I'd prefer not to show my entire code, but I'll try to get a small example working if needed.
This is on PC, HTML5 and I'm usually running in Debug mode.
Has anyone else seen this happening?
| This has never happened to me. I made a resource handler and it's a heavily modified map, but it never gives me the wrong image. I never had this happen before either, without my resource handler. You'd really need to post the code. A new set of eyes might help you find where the error is. |
| no ive never had this happen,|
are you doing everything the standard way?
(e.g. rendering in OnRender)
| Aye, I know it's not much use without example code, so I'll try to put something together.|
However, for now, I'm doing ....
Inside 'OnCreate', with the image being a field of the main game object.
It's that simple.
At least once, it's put the wrong image up, although 99% of the time, it's the correct image.
The only thing I can think, is that the image has been changed somehow, but there's nothing happening like that in my code. It's very strange, I'm not doing anything to the image except loading it in and then showing it.
| Funny enough I had this once or twice but I thought it was a html5/chrome bug or something in my code. I did not think much of it but it seems I am not the only one. It's hard to reproduce though. |
| Because you are using HTML5, maybe the browser is caching the images... I've never seen this issue though... |
| I've seen it on Android - wrong image or white rectangles being drawn occasionally. Never happened in a browser though (Chrome). |
| Ahh that's good (well, for me right now it is :p ). It does seem like a vague, and very occasional bug. I don't see how it could be my code, unless somehow I'm changing the image during run-time, which I'm certain I'm not. I'm just using the code above and I've done a search to ensure I haven't accidentally altered the image, but it's only in my code 3 times - once to declare it as a field, once to load it and once to show it.|
Should've mentioned I'm using Firefox.
| If it happens again, I'd navigate to the build folder to have a look at the image directly to see if it's correct. Also take a look at the generated main.js code and check the filenames and image references are correct. |
| Would certainly be interesting if this can be narrowed down to a small example that's reproducible in eg. HTML5.|
I've definitely seen this happen on certain older Android devices (as discussed in other threads) where sometimes eg. the built-in font is rendered occasionally (just for an odd frame every so often) instead of the expected image.
Best I managed was to narrow it down to a change introduced with Monkey v44. Prior to that, the problem didn't exist on any of those same Android devices. So, you could try rebuilding with eg. Money v43 and see what happens?
Here's one thread on the subject...
| The problem is that it's very hard to reproduce, since it only happens on very rare occasions. 99% of the time, everything is fine. Also, if it does happen, it's as if it's loaded in the wrong file completely, because the incorrect graphic shows until I restart. However, on most occasions, the correct file loads up and everything runs fine - it doesn't change mid-way through the game or anything.|
I should perhaps also point out that this seems to have happened only after I had about 20 or so images - before that, I'd never seen it.
I'm not really worried about it. I'm only working on a sample project to teach myself the Monkey language and don't intend to release it - or at least, not to sell it. I might slap it up on the forums as a showcase project, but it's not very good so I'm not worried about the bug, but thought it might be worth mentioning.
I'm also struggling with sounds and having the same problems I've seen mentioned on the forums, e.g a sound is sometimes ignored or played at different volumes. This is discussed in other threads though. Again, I'm not too worried about it right now as my project isn't serious and Monkey is still being improved daily.
| By any chance are you storing your files in a DropBox?|
When I was trying to run the whole thing out of DropBox, I ran into problems where builds wouldn't complete because it thought it couldn't find files.
Also, how often do you delete your build folder?
Do you have any source control software running that may be locking/moving files?
Lastly, doesn't Monkey have a "history" folder that gets really huge over time? Could that be corrupting hist builds somehow?
| None of the above. Since I'm new to Monkey, I made a very simple game and didn't try anything clever, or use any add-ons or stuff. There are quite a lot of images (about 30 now) including a big start-screen but I'm not using a Dropbox (don't even know what that is).|
I've never deleted my folder. Would that help? Would be interested to know why since I'm learning Monkey and am interested in any details.
Not sure about the source control software.
I 'think' I'm right in saying that once the game is running fine, the error won't occur. In other words, if I get myself killed and restart, the graphics stay fine. It's only if I turn off the game and reload it that it sometimes happens.
I realise none of this would be of any use to Mark unless I could track down what's causing it, so it's probably worth investigating further.