Cannot Load Images (Mac OSX)
BlitzMax Forums/BlitzMax Beginners Area/Cannot Load Images (Mac OSX)
| ||
********* F I X E D Turns out the file was named ship.png but was actually a gif file with the extension hidden (I didn't save it properly) so Max was actually looking for a file called ship.png.gif and obviously couldn't find it. ********* I've used BlitzMax in the past on Windows but now use Mac OS (Snow Leopard). My attempts at learning the language again have hit a wall by the fact that images will not load at all when I run the program. I've tried following the beginner tutorial and referencing the image locally on my HD but the debug tells me that I'm trying to reference a null object. Code I'm using; Graphics 800, 600, 0 Type TSpaceShip Field X:Int Field Y:Int Field Image:TImage Method DrawSelf() DrawImage Image,X,Y End Method End Type SpaceShip:TSpaceShip = New TSpaceShip HideMouse() ImageName:String = "/img/ship.png" SpaceShip.Image:TImage = LoadImage(ImageName) If Spaceship.Image = Null Print "failed to load Image" End EndIf Repeat Cls SpaceShip.X = MouseX() SpaceShip.Y = 480 SpaceShip.DrawSelf() Flip Until MouseHit(1) End XCode is installed (since it has to be to compile anything in BMax) but I'm wondering if there's anything else I need to install? Or am I just missing something glaringly obvious? Last edited 2010 |
| ||
Try removing the first forward slash from the path in ImageName; i.e. ImageName:String = "img/ship.png". Also, try: Method DrawSelf() DrawImage Self.Image, Self.X, Self.Y End Method Oh - also get into the habit of using Strict (or SuperStrict) at the top of your code. This 'forces' you to declare variables etc before you use them. Much easier to debug that way. Last edited 2010 |
| ||
*EDIT* Fixed. Turns out the file was named ship.png but was actually a gif file with the extension hidden (I didn't save it properly) so Max was actually looking for a file called ship.png.gif and obviously couldn't find it. Last edited 2010 |