TAnimation

Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Neue Antwort erstellen

beanage.johannes

Betreff: TAnimation

BeitragDo, Aug 20, 2009 15:03
Antworten mit Zitat
Benutzer-Profile anzeigen
Hier mein TAnimation modul.
mit dem modul ist es möglich verschiedene animationen abzuspeichern und mit

an:TAnimation.play(x%,y%) aufzurufen
Code: [AUSKLAPPEN]
'TAnimation Module.. by Johannes Wolf

Type TAnimation

   Field name:String
   Field id:Int
   
   Field timer:TTimer
   Field last:Int

   Field image:TImage
   Field length:Int
   
   Field cFrame:Int
   Field sFrame:Int
   Field eFrame:Int
   
   Function Create:TAnimation(_name:String,_id:Int,hertz:Int,_image:TImage,_sFrame:Int,_eFrame:Int)
   
      Local n:TAnimation = New TAnimation
      
         n.name    = _name
         n.id    = _id
         n.timer    = CreateTimer(hertz)
         n.image    = _image
         n.length = _image.frames.length
         n.cFrame = _sFrame
         n.sFrame = _sFrame
         n.eFrame = _eFrame
         
      Return n
      
   EndFunction
   
   Method play(x:Int,y:Int,rp:Int = 0)
   
      If cFrame < eFrame Then
      
         If TimerTicks(timer:TTimer) Mod 2 <> last Then
            cFrame:+1
            If cFrame = eframe Then cFrame = sFrame
      
         EndIf
            
            last = TimerTicks(timer:TTimer) Mod 2
            DrawImage image,x,y,cFrame
      EndIf
      
   EndMethod
   
   Method SetFrame(frame:Int)
   
      cFrame = frame
   
   EndMethod
   
EndType


Hier mein Testap... (tileset müsst ihr selber malen)
Code: [AUSKLAPPEN]
Include "TAnimation.bmx"

Global image:TImage = LoadAnimImage("anim.png",64,128,0,8)

Global ani:TAnimation = TAnimation.Create("test",0,4,image,1,3)

Graphics 800,600

Repeat
Cls

   ani.play(100,100)

Flip
Until AppTerminate()

ComNik

BeitragDo, Aug 20, 2009 17:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Har har bei mir kann man Start und EndFrame festlegen Razz
(nich ernst gemeint)
lg ComNik
WIP: Vorx.Engine

beanage.johannes

BeitragDo, Aug 20, 2009 20:25
Antworten mit Zitat
Benutzer-Profile anzeigen
hehe^^

Neue Antwort erstellen


Übersicht BlitzMax, BlitzMax NG Codearchiv & Module

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group