Added SpriteSheet support to chuck animations

This commit is contained in:
logsol 2015-01-14 17:31:38 +01:00
parent c6add97a38
commit dbde25f76e
259 changed files with 2533 additions and 5 deletions

View file

@ -107,6 +107,9 @@ function (Parent, Settings, Nc, Exception, ColorConverter, Layer) {
var texturePaths = [];
for (var i = start; i <= end; i++) {
/*
// Multiple File Animations
texturePaths.push(
Settings.GRAPHICS_PATH
+ Settings.GRAPHICS_SUBPATH_CHARACTERS
@ -115,8 +118,15 @@ function (Parent, Settings, Nc, Exception, ColorConverter, Layer) {
+ padF(i)
+ ".png"
);
*/
// Single File Animations (animation names from chuck_sheet.json, use option fromFrame=true)
texturePaths.push(
"Chuck" + arm.toUpperCaseFirstChar() + "0" + padF(i) + ".png"
);
}
var callback = function(mesh) {
self.animatedMeshesContainer[arm][key] = mesh;
Nc.trigger(Nc.ns.client.view.mesh.add, self.layerId, mesh);
@ -130,12 +140,13 @@ function (Parent, Settings, Nc, Exception, ColorConverter, Layer) {
x: 0,
y: 40 * 4
},
width: 35,
height: 40,
xScale: 0.25,
yScale: 0.25,
anchor: {
x: 0.5,
y: 0
}
},
fromFrame: true
});
}

View file

@ -58,9 +58,12 @@ function (Parent, Settings, Nc, PIXI, AbstractLayer) {
return n;
}
/*
// Single File Animations Preloading
var characterNames = ["Chuck"];
var animationSets = ["WithArms", "WithoutArms"];
var addition = "";
for (var i = 0; i < characterNames.length; i++) {
var characterName = characterNames[i];
for (var j = 1; j <= 126; j++) {
@ -79,6 +82,18 @@ function (Parent, Settings, Nc, PIXI, AbstractLayer) {
};
};
};
*/
var characterName = characterNames[0];
paths.push(
Settings.GRAPHICS_PATH
+ Settings.GRAPHICS_SUBPATH_CHARACTERS
+ characterName
+ "/Animation/"
+ "/TexturePacker"
+ "/witharms.json"
);
paths.push(
Settings.GRAPHICS_PATH

View file

@ -48,7 +48,10 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings) {
Layer.prototype.createMesh = function (texturePath, callback, options) {
var texture = PIXI.Texture.fromImage(texturePath);
var texture = (options && options.fromFrame)
? PIXI.Texture.fromFrame(texturePath)
: PIXI.Texture.fromImage(texturePath);
var mesh = new PIXI.Sprite(texture);
@ -60,7 +63,11 @@ function (Parent, PIXI, ColorRangeReplaceFilter, Settings) {
Layer.prototype.createAnimatedMesh = function (texturePaths, callback, options) {
var textures = [];
for (var i = 0; i < texturePaths.length; i++) {
var texture = PIXI.Texture.fromImage(texturePaths[i]);
var texture = (options && options.fromFrame)
? PIXI.Texture.fromFrame(texturePaths[i])
: PIXI.Texture.fromImage(texturePaths[i]);
texture.width = options.width;
texture.height = options.height;
//PIXI.texturesToUpdate.push(texture);

View file

@ -166,6 +166,17 @@ function (Parent, DomController, PIXI, Settings, Nc, Exception, GameStats, Layer
this.currentZoom = Settings.ZOOM_DEFAULT;
};
PixiView.prototype.getTexturesFromFrame = function(textureNames) {
var textures = [];
for (var i = 0; i < textureNames.length; i++) {
textures.push(PIXI.Texture.fromFrame(textureNames[i]));
};
return textures;
};
PixiView.prototype.destroy = function() {
this.layerManager.destroy(); // also calls all layers destroy