Beginner , Method Draw Problem

BlitzMax Forums/BlitzMax Beginners Area/Beginner , Method Draw Problem

Hi , i´m new to Bmax !

This Example gives me a bit headache .

When i try to Draw an image with the drawObj() Method, the Program crashes .
It works fine when i draw Text only ....
The Drawimage command is in comment mode now.....

 
Graphics 800,600

Switchknob:Timage = LoadAnimImage ("osc_shape.png",80,38,0,3)

' Class

Type Knob

	Field name: String
	Field x,y :Int
	Field frames:Int

	Method drawObj()
		DrawText "NAME:" + name +" POS " + " X: " + X + " Y: " + Y  + "   FRAMES: "+ Frames, X , Y
		'DrawImage Switchknob,X,Y,Frames
	End Method

End Type

' Objects
Local oscOne:knob = New knob
	
	oscOne.name = " OSC I  "
	oscOne.x = 20 ; oscOne.y = 40
	oscOne.frames = 1
	
Local oscTwo:knob= New knob

	oscTwo.name = " OSC II "  
	oscTwo.x = 20 ; oscTwo.y = 150
	oscTwo.Frames = 0

Local  oscThree:knob = New knob

	oscThree.name = " OSC III  "
	oscThree.x = 20 ; oscThree.y = 200
	oscThree.Frames = 3

Repeat
	

	oscOne.drawObj()
	oscTwo.drawObj()
	oscThree.drawObj()
	
Flip;Cls
Until KeyHit(KEY_ESCAPE)
End




Try making SwitchKnob:TImage Global.

Thx man !
Fast Replies !
.....it comes always down to the basics...

When you are new to BMax and may not know the SuperStrict command yet, try it out in the first line of your code. It will force you to declare any used variable and thus helps to avoid a lot of problems.

Thx jsp ,

just implemented it .......correted my code :-)

D

Hello.

Personally i prefer not using global variables. Put a reference to image inside the type. treat of that every type is autocontained.

Bye,
Paposo