c2ephp

sprites/SpriteFile.php

Go to the documentation of this file.
00001 <?php
00002 
00004 abstract class SpriteFile {
00005 
00007     
00008   private $frames = array();
00009   private $spritefiletype;
00011 
00013   
00014   public function SpriteFile($filetype) {
00015     $this->spritefiletype = $filetype;
00016   }
00018 
00020 
00024   public function GetFrame($frame) {
00025       return $this->frames[$frame];
00026   }
00028 
00031   public function GetFrames() {
00032       return $this->frames;
00033   }
00034 
00036 
00039   public abstract function Compile();
00040 
00042 
00057   public function AddFrame(SpriteFrame $frame, $position=false) {
00058       /*
00059       if($position === false) {
00060           $position = sizeof($this->frames);
00061       } else if($position < 0) {
00062           $position = sizeof($this->frames) - $position;
00063       }
00064       */
00065       if($this->spritefiletype == substr(get_class($frame),0,3)) {
00066           //$this->frames[$position] = $frame;
00067           $this->frames[] = $frame;
00068       } else {
00069           //$this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
00070           $this->frames[] = $frame->ToSpriteFrame($this->spritefiletype);
00071       }
00072   }
00074 
00081   public function ReplaceFrame(SpriteFrame $frame, $position) {
00082       if($position < 0) {
00083           $position = sizeof($this->frames) - $position;
00084       }
00085       $this->frames[$position] = $frame->ToSpriteFrame($this->spritefiletype);
00086   }
00088 
00091   public function GetFrameCount() {
00092       return sizeof($this->frames);
00093   }
00095 
00098   public function DeleteFrame($frame) {
00099       unset($this->frames[$frame]);
00100   }
00102 
00108   public function ToPNG($frame) {
00109       return $this->frames[$frame]->ToPNG();
00110   }
00111 }
00112 ?>
 All Classes Files Functions Variables Enumerations