@@ -2697,6 +2697,16 @@ var Sprite = (function (_super) {
26972697 enumerable : true ,
26982698 configurable : true
26992699 } ) ;
2700+ Object . defineProperty ( Sprite . prototype , "frameName" , {
2701+ get : function ( ) {
2702+ return this . animations . frameName ;
2703+ } ,
2704+ set : function ( value ) {
2705+ this . animations . frameName = value ;
2706+ } ,
2707+ enumerable : true ,
2708+ configurable : true
2709+ } ) ;
27002710 Sprite . prototype . render = function ( camera , cameraOffsetX , cameraOffsetY ) {
27012711 // Render checks
27022712 if ( this . visible === false || this . scale . x == 0 || this . scale . y == 0 || this . alpha < 0.1 || this . inCamera ( camera . worldView ) == false ) {
@@ -2721,7 +2731,7 @@ var Sprite = (function (_super) {
27212731 this . _dy = cameraOffsetY + ( this . bounds . y - camera . worldView . y ) ;
27222732 this . _dw = this . bounds . width * this . scale . x ;
27232733 this . _dh = this . bounds . height * this . scale . y ;
2724- if ( this . animations . currentFrame ) {
2734+ if ( this . animations . currentFrame !== null ) {
27252735 this . _sx = this . animations . currentFrame . x ;
27262736 this . _sy = this . animations . currentFrame . y ;
27272737 if ( this . animations . currentFrame . trimmed ) {
@@ -5624,7 +5634,7 @@ var Keyboard = (function () {
56245634 } , false ) ;
56255635 } ;
56265636 Keyboard . prototype . onKeyDown = function ( event ) {
5627- event . preventDefault ( ) ;
5637+ // event.preventDefault();
56285638 if ( ! this . _keys [ event . keyCode ] ) {
56295639 this . _keys [ event . keyCode ] = {
56305640 isDown : true ,
@@ -5637,7 +5647,7 @@ var Keyboard = (function () {
56375647 }
56385648 } ;
56395649 Keyboard . prototype . onKeyUp = function ( event ) {
5640- event . preventDefault ( ) ;
5650+ // event.preventDefault();
56415651 if ( ! this . _keys [ event . keyCode ] ) {
56425652 this . _keys [ event . keyCode ] = {
56435653 isDown : false ,
@@ -7922,7 +7932,7 @@ var Device = (function () {
79227932/**
79237933* Phaser
79247934*
7925- * v0.7 - April 14th 2013
7935+ * v0.7a - April 15th 2013
79267936*
79277937* A small and feature-packed 2D canvas game framework born from the firey pits of Flixel and Kiwi.
79287938*
@@ -7968,7 +7978,7 @@ var Game = (function () {
79687978 } , false ) ;
79697979 }
79707980 }
7971- Game . VERSION = 'Phaser version 0.7 ' ;
7981+ Game . VERSION = 'Phaser version 0.7a ' ;
79727982 Game . prototype . boot = function ( parent , width , height ) {
79737983 var _this = this ;
79747984 if ( ! document . body ) {
@@ -8193,6 +8203,7 @@ var Game = (function () {
81938203var FrameData = ( function ( ) {
81948204 function FrameData ( ) {
81958205 this . _frames = [ ] ;
8206+ this . _frameNames = [ ] ;
81968207 }
81978208 Object . defineProperty ( FrameData . prototype , "total" , {
81988209 get : function ( ) {
@@ -8202,12 +8213,22 @@ var FrameData = (function () {
82028213 configurable : true
82038214 } ) ;
82048215 FrameData . prototype . addFrame = function ( frame ) {
8216+ frame . index = this . _frames . length ;
82058217 this . _frames . push ( frame ) ;
8218+ if ( frame . name !== '' ) {
8219+ this . _frameNames [ frame . name ] = frame . index ;
8220+ }
82068221 return frame ;
82078222 } ;
8208- FrameData . prototype . getFrame = function ( frame ) {
8209- if ( this . _frames [ frame ] ) {
8210- return this . _frames [ frame ] ;
8223+ FrameData . prototype . getFrame = function ( index ) {
8224+ if ( this . _frames [ index ] ) {
8225+ return this . _frames [ index ] ;
8226+ }
8227+ return null ;
8228+ } ;
8229+ FrameData . prototype . getFrameByName = function ( name ) {
8230+ if ( this . _frameNames [ name ] >= 0 ) {
8231+ return this . _frames [ this . _frameNames [ name ] ] ;
82118232 }
82128233 return null ;
82138234 } ;
@@ -8244,7 +8265,9 @@ var FrameData = (function () {
82448265/// <reference path="AnimationLoader.ts" />
82458266/// <reference path="FrameData.ts" />
82468267var Frame = ( function ( ) {
8247- function Frame ( x , y , width , height ) {
8268+ function Frame ( x , y , width , height , name ) {
8269+ // Useful for Texture Atlas files (is set to the filename value)
8270+ this . name = '' ;
82488271 // Rotated? (not yet implemented)
82498272 this . rotated = false ;
82508273 // Either cw or ccw, rotation is always 90 degrees
@@ -8253,6 +8276,7 @@ var Frame = (function () {
82538276 this . y = y ;
82548277 this . width = width ;
82558278 this . height = height ;
8279+ this . name = name ;
82568280 this . rotated = false ;
82578281 this . trimmed = false ;
82588282 }
@@ -8399,15 +8423,8 @@ var AnimationLoader = (function () {
83998423 var data = new FrameData ( ) ;
84008424 var x = 0 ;
84018425 var y = 0 ;
8402- //console.log('\n\nSpriteSheet Data');
8403- //console.log('Image Size:', width, 'x', height);
8404- //console.log('Frame Size:', frameWidth, 'x', frameHeight);
8405- //console.log('Start X/Y:', x, 'x', y);
8406- //console.log('Frames (Total: ' + total + ')');
8407- //console.log('-------------');
84088426 for ( var i = 0 ; i < total ; i ++ ) {
8409- data . addFrame ( new Frame ( x , y , frameWidth , frameHeight ) ) ;
8410- //console.log('Frame', i, '=', x, y);
8427+ data . addFrame ( new Frame ( x , y , frameWidth , frameHeight , '' ) ) ;
84118428 x += frameWidth ;
84128429 if ( x === width ) {
84138430 x = 0 ;
@@ -8423,9 +8440,8 @@ var AnimationLoader = (function () {
84238440 var frames = json ;
84248441 var newFrame ;
84258442 for ( var i = 0 ; i < frames . length ; i ++ ) {
8426- newFrame = data . addFrame ( new Frame ( frames [ i ] . frame . x , frames [ i ] . frame . y , frames [ i ] . frame . w , frames [ i ] . frame . h ) ) ;
8443+ newFrame = data . addFrame ( new Frame ( frames [ i ] . frame . x , frames [ i ] . frame . y , frames [ i ] . frame . w , frames [ i ] . frame . h , frames [ i ] . filename ) ) ;
84278444 newFrame . setTrim ( frames [ i ] . trimmed , frames [ i ] . sourceSize . w , frames [ i ] . sourceSize . h , frames [ i ] . spriteSourceSize . x , frames [ i ] . spriteSourceSize . y , frames [ i ] . spriteSourceSize . w , frames [ i ] . spriteSourceSize . h ) ;
8428- newFrame . filename = frames [ i ] . filename ;
84298445 }
84308446 return data ;
84318447 } ;
@@ -8635,6 +8651,21 @@ var Animations = (function () {
86358651 enumerable : true ,
86368652 configurable : true
86378653 } ) ;
8654+ Object . defineProperty ( Animations . prototype , "frameName" , {
8655+ get : function ( ) {
8656+ return this . currentFrame . name ;
8657+ } ,
8658+ set : function ( value ) {
8659+ this . currentFrame = this . _frameData . getFrameByName ( value ) ;
8660+ if ( this . currentFrame !== null ) {
8661+ this . _parent . bounds . width = this . currentFrame . width ;
8662+ this . _parent . bounds . height = this . currentFrame . height ;
8663+ this . _frameIndex = this . currentFrame . index ;
8664+ }
8665+ } ,
8666+ enumerable : true ,
8667+ configurable : true
8668+ } ) ;
86388669 return Animations ;
86398670} ) ( ) ;
86408671/// <reference path="Game.ts" />
0 commit comments