Skip to content

Commit

Permalink
working version 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mientjan committed May 6, 2016
1 parent 7515062 commit 91ddfa6
Show file tree
Hide file tree
Showing 26 changed files with 453 additions and 155 deletions.
163 changes: 100 additions & 63 deletions bin/pixi-flump.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/pixi-flump.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bin/pixi-flump.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion bin/pixi-flump.min.js.map

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions example/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ document.body.appendChild(renderer.view);
// create the root of the scene graph
var stage = new PIXI.Container();

var fl = new PIXI.FlumpLibrary('../test/assets/flump/animations-100/character');
var fl = new PIXI.FlumpLibrary('../test/assets/flump/animation-100/character');


fl.load().then(function(library){

for(var i = 0; i < 1000; i++)
for(var i = 0; i < 200; i++)
{

var movie = fl.createMovie(names[Math.floor(Math.random()*names.length)]);
var name = names[Math.floor(Math.random()*names.length)];
var movie = fl.createMovie(name);
// console.log(name);

// var movie = fl.createMovie('cubeAnimation');
movie.position.set(Math.random() * width|0, Math.random() * height|0);
movie.play(-1)
stage.addChild(movie);
Expand All @@ -42,6 +45,7 @@ fl.load().then(function(library){
} else {
var delta = time - pTime;
pTime = time;


for(var i = 0; i < stage.children.length; i++)
{
Expand All @@ -54,5 +58,5 @@ fl.load().then(function(library){
}


}).catch(err => console.log(err));
}).catch(function(err){console.log(err)});

5 changes: 2 additions & 3 deletions src/FlumpLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ var FlumpLibrary = (function () {
FlumpLibrary.prototype.createSymbol = function (name, paused) {
if (paused === void 0) { paused = false; }
for (var i = 0; i < this.textureGroups.length; i++) {
var textures = this.textureGroups[i].sprites;
if (name in textures) {
return textures[name];
if (this.textureGroups[i].hasSprite(name)) {
return this.textureGroups[i].createSprite(name);
}
}
for (var i = 0; i < this.movieData.length; i++) {
Expand Down
7 changes: 2 additions & 5 deletions src/FlumpLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,8 @@ export class FlumpLibrary implements ILoadable<FlumpLibrary>
{
for(var i = 0; i < this.textureGroups.length; i++)
{
var textures = this.textureGroups[i].sprites;

if(name in textures)
{
return textures[name];
if(this.textureGroups[i].hasSprite(name)){
return this.textureGroups[i].createSprite(name);
}
}

Expand Down
22 changes: 17 additions & 5 deletions src/core/MovieLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var __extends = (this && this.__extends) || function (d, b) {
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var FlumpMtx_1 = require("./FlumpMtx");
var FlumpMovie_1 = require("./FlumpMovie");
var LabelData_1 = require("../data/LabelData");
var KeyframeData_1 = require("../data/KeyframeData");
Expand All @@ -16,7 +15,6 @@ var MovieLayer = (function (_super) {
this._frame = 0;
this._symbols = {};
this.enabled = true;
this._storedMtx = new FlumpMtx_1.FlumpMtx(1, 0, 0, 1, 0, 0);
var keyframeData = layerData.keyframeData;
this._index = index;
this._movie = movie;
Expand Down Expand Up @@ -132,9 +130,23 @@ var MovieLayer = (function (_super) {
alpha = alpha + (nextKeyframe.alpha - alpha) * interped;
}
}
symbol.setTransform(x, y, scaleX, scaleY, 0, skewX, skewY, pivotX, pivotY);
symbol.visible = keyframe.visible;
symbol.alpha = alpha;
if (skewX != 0) {
sinX = Math.sin(skewX);
cosX = Math.cos(skewX);
}
if (skewY != 0) {
sinY = Math.sin(skewY);
cosY = Math.cos(skewY);
}
this._symbol.position.set(x, y);
this._symbol.scale.set(scaleX, scaleY);
if (!(this._symbol instanceof PIXI.Sprite)) {
this._symbol['pivot'].x = pivotX;
this._symbol['pivot'].y = pivotY;
}
this._symbol['skew'].set(skewX, skewY);
this.alpha = alpha;
this.visible = keyframe.visible;
this._frame = frame;
};
MovieLayer.prototype.reset = function () {
Expand Down
69 changes: 46 additions & 23 deletions src/core/MovieLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class MovieLayer extends PIXI.Container
// disable layer from code
public enabled:boolean = true;

public _storedMtx = new FlumpMtx(1, 0, 0, 1, 0, 0);
// public _storedMtx = new FlumpMtx(1, 0, 0, 1, 0, 0);

constructor(index:number, movie:FlumpMovie, library:FlumpLibrary, layerData:LayerData)
{
Expand Down Expand Up @@ -198,40 +198,63 @@ export class MovieLayer extends PIXI.Container
}
}

this.setTransform(x, y, scaleX, scaleY, 0, skewX, skewY, pivotX, pivotY)
this.visible = keyframe.visible;
this.alpha = alpha;
//this.setTransform(x, y, scaleX, scaleY, 0, skewX, skewY, pivotX, pivotY)

// if(skewX != 0)
// {
// sinX = Math.sin(skewX);
// cosX = Math.cos(skewX);
// }
//
// if(skewY != 0)
// {
// sinY = Math.sin(skewY);
// cosY = Math.cos(skewY);
// }

if(skewX != 0)
{
sinX = Math.sin(skewX);
cosX = Math.cos(skewX);
}

if(skewY != 0)
{
sinY = Math.sin(skewY);
cosY = Math.cos(skewY);
}
//
// symbol.localTransform
//
// this._storedMtx.a = scaleX * cosY;
// this._storedMtx.b = scaleX * sinY;
// this._storedMtx.c = -scaleY * sinX;
// this._storedMtx.d = scaleY * cosX;
// this.worldTransform.a = scaleX * cosY;
// this.worldTransform.b = scaleX * sinY;
// this.worldTransform.c = -scaleY * sinX;
// this.worldTransform.d = scaleY * cosX;
//
// this._storedMtx.tx = x - (pivotX * this._storedMtx.a + pivotY * this._storedMtx.c);
// this._storedMtx.ty = y - (pivotX * this._storedMtx.b + pivotY * this._storedMtx.d);
// this.worldTransform.tx = x - (pivotX * this.worldTransform.a + pivotY * this.worldTransform.c);
// this.worldTransform.ty = y - (pivotX * this.worldTransform.b + pivotY * this.worldTransform.d);

this._symbol.position.set(x, y);
this._symbol.scale.set(scaleX, scaleY);
if(!(this._symbol instanceof PIXI.Sprite))
{
this._symbol['pivot'].x = pivotX;
this._symbol['pivot'].y = pivotY;
}
this._symbol['skew'].set(skewX, skewY);

// this.alpha = alpha;
// console.log(pivotX, pivotY);

// console.log(this.worldTransform);

//
// this.setTransform(this._storedMtx.tx, this._storedMtx.ty, this._storedMtx.a, this._storedMtx.d, 0, this._storedMtx.b, this._storedMtx.c, 0, 0)
// this.worldTransform.set( this._storedMtx.a, this._storedMtx, this._storedMtx, this._storedMtx.tx, this._storedMtx.ty);
// this.setTransform(x, y, scaleX, scaleY, 0, skewX, skewY, 0, 0);
// this.visible = keyframe.visible;
// this.alpha = alpha;

this.alpha = alpha;
this.visible = keyframe.visible;

this._frame = frame;
}

public reset()
// updateTransform():void
// {
// // super.updateTransform();
// }

public reset():void
{
if(this._symbol instanceof FlumpMovie)
{
Expand Down
Loading

0 comments on commit 91ddfa6

Please sign in to comment.