CreateMapAnim
CreateMapAnim MapIndex, Animindex, NumbOfFrames
 
Parameters:

    MapIndex = The Index of the Map that you wish to create an anim within
    Animindex = The Index of the tile animation to create
    NumbOfFrames = The number of frames this anim should have
Returns: NONE
 

      CreateMapAnim initializes blank space for this block anim sequence. The sequence can store any valid block index, in any order you like. So an animation is nothing more than a list of block indexes. Each position is the animation list is called a frame. The animation frames start at 0 and go up the number of defined frames for the animation.

      When map animations are played using the UpdateMapAnims command, the command will step forward through the defined frames of your animation, until reaching the end of the animation. Where (depending upon the animation type), it will reset the animations current frame index back to the start and continue on. Creating an endless animation.

      The Number Of Frames within an Animation can be expanded or contracted as need be, using the ResizeMapAnim command. So if you create an animation with provision for 50 frames, and only use the first 10, then to ensure your animation works correctly, you'll need to resize the animation to the correct size. Which would 10 in case of this example.



FACTS:


      * Animations default to Anim Type #1 (PBMapAnim_Forward)





Mini Tutorial:


      This example shows the hands on creation of a Map, and then basic creation of a map Anim, then displays the map information for you. Which should give you a feel of all the map animations used in content.


  
; ==============================
; Part 1 - Create Map
; ==============================
  
; Set Width & Height variables of the Map tiles
  TileWidth=16
  Tileheight=16
  
  
; Create a map with provision for 5 levels
  MyMap=NewMap(5)
  
; ==============================
; Part 2 - Create Tile Animations
; ==============================
  Print "Number Of Animations in Map:"+Str$(GetMapAnims(MyMap))
  
; Create Room for 5 Block Animations with this map
  MapAnimQuantity MyMap,5
  
; Create Anim 1,with space for 10 frames in the anim
  CreateMapAnim MyMap,1,10
  
; Poke some frames into the Anim #1
  For lp=0 To 10
     PokeMapAnim MyMap,1,lp,10+lp
  Next
  
; Set the frame rate of anim #1 to 3
  MapAnimFrameRate MyMap,1,3
  
  
; ==============================
; Part 3 - Display the Anim Information
; ==============================
  
  Print "Number Of Animations in Map:"+Str$(GetMapAnims(MyMap))
  
; List the Info about each Anim
  For Anim=0 To GetMapAnims(MyMap)
     
   ; Check if this Anim exists or not ?
     If  GetMapAnimStatus(MyMap,Anim)=true
        
      ; Display all of the info about this Anim
        Print "Anim #"+Str$(anim)
        f$=""
        Print "Frames:"+Str$(GetMapAnimSize(mymap,anim))
        Print "Frame Rate:"+Str$(GetMapAnimFrameRate(mymap,anim))
        Print "Current Frame Rate:"+Str$(GetMapAnimCurrentFrameRate(mymap,anim))
        Print "Anim Type:"+Str$(GetMapAnimType(mymap,anim))
        For Frames=0 To GetMapAnimSize(myMap,Anim)
           f$=f$+Str$(PeekMapAnim(myMap,anim,Frames))+","
        Next
        Print "Tile Sequence:"+TrimRight$(F$,",")
     Else
        Print "Anim #"+Str$(anim)+" Doesn't exist"
     EndIf
     Print ""
  Next
  
; Display the screen and loop back to the DO
  Sync
  WaitKey
  



This example would output.

  
  Number Of Animations in Map: 0
  Number Of Animations in Map: 5
  Anim #0 Doesn't exist
  
  Anim #1
  Frames:10
  Frame Rate:3
  Current Frame Rate:3
  Anim Type:1
  Tile Sequence:10,11,12,13,14,15,16,17,18,19,20
  
  Anim #2 Doesn't exist
  
  Anim #3 Doesn't exist
  
  Anim #4 Doesn't exist
  
  Anim #5 Doesn't exist
  

 
Related Info: DeleteMapAnim | GetMapAnimStatus :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com