mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed first animations
This commit is contained in:
parent
caa3945869
commit
142964938c
8 changed files with 159 additions and 53 deletions
|
|
@ -14,6 +14,7 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
NotificationCenter.on("view/createMesh", this.createMesh, this);
|
||||
NotificationCenter.on("view/addMesh", this.addMesh, this);
|
||||
NotificationCenter.on("view/updateMesh", this.updateMesh, this);
|
||||
NotificationCenter.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
|
||||
}
|
||||
|
||||
AbstractView.prototype.isWebGlEnabled = function () {
|
||||
|
|
@ -46,7 +47,7 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
throw new Exception('Abstract Function render not overwritten ');
|
||||
}
|
||||
|
||||
AbstractView.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
||||
AbstractView.prototype.createMesh = function (texturePath, callback, options) {
|
||||
throw new Exception('Abstract Function createMesh not overwritten ');
|
||||
}
|
||||
|
||||
|
|
@ -58,6 +59,10 @@ function (DomController, Settings, Exception, NotificationCenter) {
|
|||
throw new Exception('Abstract Function updateMesh not overwritten ');
|
||||
};
|
||||
|
||||
AbstractView.prototype.createAnimatedMesh = function (texturePaths, callback, options) {
|
||||
throw new Exception('Abstract Function createAnimatedMesh not overwritten ');
|
||||
}
|
||||
|
||||
AbstractView.prototype.setMe = function(player) {
|
||||
this.me = player;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,15 +48,28 @@ function (Parent, DomController, PIXI, Settings) {
|
|||
this.container.addChild(mesh);
|
||||
};
|
||||
|
||||
PixiView.prototype.createMesh = function (width, height, x, y, imgPath, callback) {
|
||||
PixiView.prototype.createMesh = function (texturePath, callback, options) {
|
||||
|
||||
var texture = PIXI.Texture.fromImage(imgPath);
|
||||
var texture = PIXI.Texture.fromImage(texturePath);
|
||||
|
||||
var mesh = new PIXI.Sprite(texture);
|
||||
mesh.width = width;
|
||||
mesh.height = height;
|
||||
mesh.position.x = x;
|
||||
mesh.position.y = y;
|
||||
if(options) this.updateMesh(mesh, options);
|
||||
|
||||
callback(mesh);
|
||||
}
|
||||
|
||||
PixiView.prototype.createAnimatedMesh = function (texturePaths, callback, options) {
|
||||
var textures = [];
|
||||
for (var i = 0; i < texturePaths.length; i++) {
|
||||
var texture = PIXI.Texture.fromImage(texturePaths[i]);
|
||||
textures.push(texture);
|
||||
}
|
||||
|
||||
var mesh = new PIXI.MovieClip(textures);
|
||||
if(options) this.updateMesh(mesh, options);
|
||||
mesh.animationSpeed = 0.5;
|
||||
|
||||
mesh.play();
|
||||
|
||||
callback(mesh);
|
||||
}
|
||||
|
|
@ -69,7 +82,22 @@ function (Parent, DomController, PIXI, Settings) {
|
|||
if (options.yScale) mesh.scale.y = options.yScale;
|
||||
if (options.width) mesh.width = options.width;
|
||||
if (options.height) mesh.height = options.height;
|
||||
};
|
||||
if (options.visible === true || options.visible === false) mesh.visible = options.visible;
|
||||
if (options.pivot) {
|
||||
switch(options.pivot) {
|
||||
case "mb":
|
||||
mesh.pivot.x = mesh.width / 2;
|
||||
mesh.pivot.y = mesh.height;
|
||||
break;
|
||||
case "mm":
|
||||
default:
|
||||
mesh.pivot.x = mesh.width / 2;
|
||||
mesh.pivot.y = mesh.height / 2;
|
||||
break;
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
PixiView.prototype.initCamera = function () {
|
||||
this.container = new PIXI.DisplayObjectContainer();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue