diff --git a/.gitignore b/.gitignore
index 298140c..763d2ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,4 +7,6 @@ docs
.settings
.actionScriptProperties
.project
-.git
\ No newline at end of file
+.git
+/.flexLibProperties
+/bin/Axel.swc
diff --git a/src/org/axgl/AxButton.as b/src/org/axgl/AxButton.as
index 8449235..29ef572 100644
--- a/src/org/axgl/AxButton.as
+++ b/src/org/axgl/AxButton.as
@@ -72,7 +72,7 @@ package org.axgl {
*/
public function text(str:String, font:AxFont = null, verticalOffset:uint = 10, horizontalOffset:uint = 0):AxButton {
if (font == null) {
- font = AxResource.font;
+ font = AxResource.FONT;
}
labelY = verticalOffset;
diff --git a/src/org/axgl/AxSprite.as b/src/org/axgl/AxSprite.as
index b01967b..0795440 100644
--- a/src/org/axgl/AxSprite.as
+++ b/src/org/axgl/AxSprite.as
@@ -260,6 +260,31 @@ package org.axgl {
animations[name] = new AxAnimation(name, frames, framerate < 1 ? 15 : framerate, looped, callback);
return this;
}
+
+ /**
+ * Adds a new animation to this sprite. The name of the animation is what you will use to access it via the animate
+ * function. The firstFrame is first frame ID. The frameNum is total number of the frame. Framerate is
+ * how fast the animation will play; it indicates how many frames will be played per second. If you have a 5 frame animation with a
+ * framerate of 10, it will play the animation twice per second. The looped parameter indicates whether or not this
+ * animation should stop at the end of the animation, or if it should loop repeatedly.
+ *
+ * @param name The name of the animation.
+ * @param firstFrame The firstFrame represents the first frame ID.
+ * @param frameNum The frameNum represents the total number of frames.
+ * @param framerate The framerate at which the animation should play.
+ * @param looped Whether or not the animation should loop.
+ *
+ * @return The sprite instance.
+ */
+ public function addAnimationByFristFrame(name:String, firstFrame:uint, frameNum:uint = 1, framerate:uint = 15, looped:Boolean = true, callback:Function = null):AxSprite{
+
+ var frames:Array = [];
+ var endFrame:int = firstFrame + frameNum;
+ for(var i:int = firstFrame; i < endFrame; i++){
+ frames.push(i);
+ }
+ return this.addAnimation(name,frames,framerate,looped,callback);
+ }
/**
* Tells this sprite to immediately start playing the animation that you passed. If that animation is already playing,
@@ -300,15 +325,20 @@ package org.axgl {
*/
private function calculateFrame():void {
if (animation != null) {
+
+ //cache value;
+ var nextFrame:uint = frame + 1;
+ var frameLen:uint = animation.frames.length;
+
animationTimer += Ax.dt;
while (animationTimer >= animationDelay) {
animationTimer -= animationDelay;
- if (frame + 1 < animation.frames.length || animation.looped) {
- frame = (frame + 1) % animation.frames.length;
+ if (nextFrame < frameLen || animation.looped) {
+ frame = nextFrame % frameLen;
}
uvOffset[0] = (animation.frames[frame] % framesPerRow) * quad.uvWidth;
uvOffset[1] = Math.floor(animation.frames[frame] / framesPerRow) * quad.uvHeight;
- if (frame + 1 == animation.frames.length && animation.callback != null) {
+ if (nextFrame == frameLen && animation.callback != null) {
animation.callback();
}
}
diff --git a/src/org/axgl/resource/AxResource.as b/src/org/axgl/resource/AxResource.as
index 45674d8..6a0d9d8 100644
--- a/src/org/axgl/resource/AxResource.as
+++ b/src/org/axgl/resource/AxResource.as
@@ -13,10 +13,10 @@ package org.axgl.resource {
/* Build in Axel font */
[Embed(source = "font.png")] public static const FONT_BITMAP:Class;
- public static var font:AxFont;
+ public static var FONT:AxFont;
public static function initialize():void {
- font = AxFont.fromBitmap(FONT_BITMAP, 1, 0);
+ FONT = AxFont.fromBitmap(FONT_BITMAP, 1, 0);
}
}
}
\ No newline at end of file
diff --git a/src/org/axgl/text/AxText.as b/src/org/axgl/text/AxText.as
index 6c67db7..846fa45 100644
--- a/src/org/axgl/text/AxText.as
+++ b/src/org/axgl/text/AxText.as
@@ -54,7 +54,7 @@ package org.axgl.text {
super(x, y, VERTEX_SHADER, FRAGMENT_SHADER, 8);
this._text = text;
- this.font = font ? font : AxResource.font;
+ this.font = font ? font : AxResource.FONT;
this.width = this.requestedWidth = width;
this.align = align;
diff --git a/src/org/axgl/util/debug/AxDebugConsole.as b/src/org/axgl/util/debug/AxDebugConsole.as
index 73b5f81..a28f385 100644
--- a/src/org/axgl/util/debug/AxDebugConsole.as
+++ b/src/org/axgl/util/debug/AxDebugConsole.as
@@ -29,7 +29,7 @@ package org.axgl.util.debug {
public function AxDebugConsole() {
this.add(background = new AxSprite(0, 0));
- this.add(text = new AxText(5, 5, AxResource.font, "", Ax.viewWidth - 20));
+ this.add(text = new AxText(5, 5, AxResource.FONT, "", Ax.viewWidth - 20));
background.scroll.x = background.scroll.y = 0;
text.scroll.x = text.scroll.y = 0;
background.zooms = text.zooms = false;
diff --git a/src/org/axgl/util/debug/AxDebugger.as b/src/org/axgl/util/debug/AxDebugger.as
index 6184e22..a54fa30 100644
--- a/src/org/axgl/util/debug/AxDebugger.as
+++ b/src/org/axgl/util/debug/AxDebugger.as
@@ -49,32 +49,32 @@ package org.axgl.util.debug {
var version:Array = Ax.LIBRARY_VERSION.split(".");
var debugMode:String = Ax.debug ? "@[255,90,90]Debug" : "@[200,200,200]Release";
- libraryText = new AxText(4, 3, AxResource.font, Ax.LIBRARY_NAME + " @[160,160,160]Version @[150,150,255]" + version[0] + "@[10,255,255].@[180,180,255]" + version[1] + "@[255,255,255].@[210,210,255]" + version[2] + " " + debugMode);
+ libraryText = new AxText(4, 3, AxResource.FONT, Ax.LIBRARY_NAME + " @[160,160,160]Version @[150,150,255]" + version[0] + "@[10,255,255].@[180,180,255]" + version[1] + "@[255,255,255].@[210,210,255]" + version[2] + " " + debugMode);
libraryText.scroll.x = libraryText.scroll.y = 0;
libraryText.zooms = libraryText.countTris = false;
this.add(libraryText);
- fpsText = new AxText(4, Ax.height - HEIGHT + 3, AxResource.font, "FPS: 0/0");
+ fpsText = new AxText(4, Ax.height - HEIGHT + 3, AxResource.FONT, "FPS: 0/0");
fpsText.scroll.x = fpsText.scroll.y = 0;
fpsText.zooms = fpsText.countTris = false;
this.add(fpsText);
- memoryText = new AxText(70, Ax.height - HEIGHT + 3, AxResource.font, "Memory: 0MB");
+ memoryText = new AxText(70, Ax.height - HEIGHT + 3, AxResource.FONT, "Memory: 0MB");
memoryText.scroll.x = memoryText.scroll.y = 0;
memoryText.zooms = memoryText.countTris = false;
this.add(memoryText);
- modeText = new AxText(0, 3, AxResource.font, "---", Ax.width - 3, "right");
+ modeText = new AxText(0, 3, AxResource.FONT, "---", Ax.width - 3, "right");
modeText.scroll.x = modeText.scroll.y = 0;
modeText.zooms = modeText.countTris = false;
this.add(modeText);
- timeText = new AxText(0, Ax.height - HEIGHT + 3, AxResource.font, "---", Ax.width - 5, "right");
+ timeText = new AxText(0, Ax.height - HEIGHT + 3, AxResource.FONT, "---", Ax.width - 5, "right");
timeText.scroll.x = timeText.scroll.y = 0;
timeText.zooms = timeText.countTris = false;
this.add(timeText);
- titleText = new AxText(0, 3, AxResource.font, "", Ax.width, "center");
+ titleText = new AxText(0, 3, AxResource.FONT, "", Ax.width, "center");
titleText.scroll.x = titleText.scroll.y = 0;
titleText.zooms = titleText.countTris = false;
this.add(titleText);