Beginner , Method Draw Problem

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

Dezzo(Posted 2008) [#1]
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





GfK(Posted 2008) [#2]
Try making SwitchKnob:TImage Global.


Dezzo(Posted 2008) [#3]
Thx man !
Fast Replies !
.....it comes always down to the basics...


jsp(Posted 2008) [#4]
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.


Dezzo(Posted 2008) [#5]
Thx jsp ,

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

D


Paposo(Posted 2008) [#6]
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