Memory access violation erorr

Monkey Forums/Monkey Bug Reports/Memory access violation erorr

Citty(Posted 2014) [#1]
Hi, I just downloaded monkey-x, and I have a problem.

When I run my program:

Import mojo
Class Game Extends App

Field image:Image

Method OnCreate()
SetUpdateRate 30
image=LoadImage("Hi.png")
End

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

End

Function Main()
New Game()
End

It says, "Memory access violation" and highlights this line of code in a program called graphics.monkey

If frame<0 Or frame>=image.frames.Length Error "Invalid image frame"

I was wondering if you can fix this problem. Thanks!


rIKmAN(Posted 2014) [#2]
Hey Citty,

First you should put your code example inside [code] tags so that it will display properly on the forum - click the "forum codes" link above the reply box at the bottom of this page to see what codes are supported.

As for your problem, firstly check:

1) Your image "Hi.png" is in the .data folder for your program.
2) Your image is named correctly as per the file you are trying to load in your code ("Hi.png" and not "hi.png" etc)


Citty(Posted 2014) [#3]
I just put Hi.png in the data folder, and then when I ran the program, it deleted the data folder, and gave me the same erorr


Goodlookinguy(Posted 2014) [#4]
This is not a Monkey bug, you should use the search function or Google before posting: http://www.monkeycoder.co.nz/Community/posts.php?topic=8232


rIKmAN(Posted 2014) [#5]
Lets say your file is called myprogram.monkey

It should be in a structure as follows:

- myprogram (folder)
  - myprogram.monkey (source file)
  - myprogram.data (folder)
    - Hi.png (image file)


Hope that helps.


Citty(Posted 2014) [#6]
none of this helps because there is no data folder


rIKmAN(Posted 2014) [#7]
Create it yourself Citty, make a new folder and call it the same as your monkey source file with ".data" appended on the end, and put all your assets in here as it will be the "base" folder for loading all your assets.

Use the same structure I posted above.


dawlane(Posted 2014) [#8]
Try it with a png from one of the examples that come with Monkey. If it works then there is a problem with the png.
You will also see how a Monkey Project should be structured.
For a desktop build you will find the executable in one of the sub directories with the name Debug or Release (on windows it could be vs2010 or gcc_winnt depending on the compiler used). You will see what directories need to be with you final executable.


Citty(Posted 2014) [#9]
I just created a myprogram.data folder and my problem was in setting up the project it skipped a file and now it's fixed! Thank You!!! :D


Citty(Posted 2014) [#10]
rLKmAN You fixed my problem


rIKmAN(Posted 2014) [#11]
Congrats, glad to have helped! :)