Image not Displaying
BlitzMax Forums/BlitzMax Programming/Image not Displaying
| ||
| [Code] File: Main.bmx Framework Brl.Basic Import Brl.System Import Brl.GLMax2D Import Pub.Libpng SetMaskColor 255,0,255 Global SCREENWIDTH:Int Global SCREENHEIGHT:Int Global SCREENDEPTH:Int Global SCREENFULL:Int=False Graphics(320,240,0,60) SetViewport(32,8,256,224) SetOrigin(32,8) Include "player.bmx" PlayerSetup 0,0 'Main Loop While Not KeyHit(KEY_ESCAPE) Cls PlayerDraw PlayerX,PlayerY FlushMem Flip Wend End [/Code] [Code] FILE: player.bmx Global PlayerIdle:Int ; Incbin "gfx/idle.png" Global PlayerX:Float=0 Global PlayerY:Float=0 Function PlayerSetup(fX,fY) PlayerIdle = LoadImage("IncBin::gfx/idle.png") End Function Function PlayerDraw(fX,fY) DrawImage PlayerIdle,fX,fY End Function [/code] okay Im getting this error and why?? Unhandled Exception: Attempt to access field or method of NULL object on the DrawImage PlayerIdle,fX,fY please help... |
| ||
Framework Brl.Basic
Import Brl.System
Import Brl.GLMax2D
Import Pub.Libpng
Graphics 640,480
If LoadImage ("D:\Dev\BlitzMaxCore106\doc\bmax120.png") = Null
Print "Your Imports are wrong"
Else
Print "Your PNG image isn't correct."
End IfIncidently, the correct answer is: Your imports are wrong. |
| ||
| try : Import BRL.Pngloader instead of Import pub.libpng |
| ||
| Well I tried both and neither worked. FlameDuck: I put that if-then statement and no errors came up so I know the image is loading, but not sure what else to make of it flaith: Also the import didn't change anything either :( EDIT: okay that fixed the LoadImage, but not the LoadAnimImages there is a major bug or something in BlitzMax if this happening |
| ||
i tried that code :
Framework BRL.GLMax2D
Import BRL.Basic
Import BRL.System
Import BRL.Pngloader
Graphics 640,480,0
Incbin "gfx/Pipe.png"
Incbin "gfx/Robi.png"
Const BOARD_WIDTH = 33
Const BOARD_HEIGHT = 33
'MASKBLEND marche mieux avec pipe_3 car les couleurs sont indéxées
'voir dans Gimp différence entre le pipe.png et le pipe_3.png
SetMaskColor 255,0,255
Global pipe:TImage = LoadAnimImage ("incbin::gfx/Pipe.png" ,BOARD_WIDTH, BOARD_HEIGHT,0,17,MASKEDIMAGE)
Global robi:TImage = LoadAnimImage ("incbin::gfx/Robi.png" ,BOARD_WIDTH, BOARD_HEIGHT,0,8,MASKEDIMAGE)
SetClsColor 128,128,128
While Not KeyHit(KEY_ESCAPE)
Cls
For Local i = 0 To 8
DrawImage pipe,10,50+(i*33),i
Next
Flip
Wend
run ok for me !!! |
| ||
| I put that if-then statement and no errors came up so I know the image is loading, but not sure what else to make of it An error isn't SUPPOSED to come up. It's supposed to print "There is a problem with your imports" in the console. And it does, because there is a problem with your imports. Also the import didn't change anything either :( EDIT: okay that fixed the LoadImage, but not the LoadAnimImages there is a major bug or something in BlitzMax if this happening It is not a major bug in BlitzMAX (or any bug at that). Remove all your import and framework statements and it'll work fine, because it's a problem with your imports. |