Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ docs
.settings
.actionScriptProperties
.project
.git
.git
/.flexLibProperties
/bin/Axel.swc
2 changes: 1 addition & 1 deletion src/org/axgl/AxButton.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
36 changes: 33 additions & 3 deletions src/org/axgl/AxSprite.as
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>name</code> of the animation is what you will use to access it via the <code>animate</code>
* function. The <code>firstFrame</code> is first frame ID. The <code>frameNum</code> is total number of the frame. <code>Framerate</code> 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 <code>looped</code> 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,
Expand Down Expand Up @@ -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();
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/axgl/resource/AxResource.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
2 changes: 1 addition & 1 deletion src/org/axgl/text/AxText.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/org/axgl/util/debug/AxDebugConsole.as
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/org/axgl/util/debug/AxDebugger.as
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down