fixed skateboard and mesh positioning

This commit is contained in:
Jeena 2014-01-16 19:33:37 +01:00
parent 7220e3b388
commit bdab2a5760
9 changed files with 83 additions and 45 deletions

View file

@ -138,7 +138,7 @@ function (Parent, Settings, NotificationCenter, Exception) {
this.headMesh,
{
x: this.body.GetPosition().x * Settings.RATIO,
y: this.body.GetPosition().y * Settings.RATIO - 31
y: this.body.GetPosition().y * Settings.RATIO - this.height + this.headHeight
}
)
}

View file

@ -31,8 +31,7 @@ function (Parent, Settings, NotificationCenter) {
callback,
{
width: Settings.TILE_SIZE,
height: Settings.TILE_SIZE,
pivot: "mb"
height: Settings.TILE_SIZE
}
);
};
@ -47,8 +46,8 @@ function (Parent, Settings, NotificationCenter) {
NotificationCenter.trigger("view/updateMesh",
this.mesh,
{
x: this.options.x * Settings.TILE_SIZE,
y: this.options.y * Settings.TILE_SIZE,
x: this.body.GetPosition().x * Settings.RATIO - Settings.TILE_SIZE / 2,
y: this.body.GetPosition().y * Settings.RATIO - Settings.TILE_SIZE / 2
}
);
}

View file

@ -89,12 +89,18 @@ function (Parent, DomController, PIXI, Settings, NotificationCenter) {
if (options.height) mesh.height = options.height;
if (options.visible === true || options.visible === false) mesh.visible = options.visible;
if (options.pivot) {
switch(options.pivot.length) {
default:
mesh.pivot.x = mesh.width / 2;
mesh.pivot.y = mesh.height;
break;
if(options.pivot.length) {
switch(options.pivot) {
case "lb":
mesh.pivot.x = mesh.width / 2;
mesh.pivot.y = mesh.height / 2;
break;
default:
mesh.pivot.x = mesh.width / 2;
mesh.pivot.y = mesh.height;
break;
}
}
};
}
@ -105,16 +111,11 @@ function (Parent, DomController, PIXI, Settings, NotificationCenter) {
}
PixiView.prototype.calculateCameraPosition = function() {
var reference = this.me.getPosition();
var pos = {};
pos.x = -reference.x;
pos.y = reference.y;
var zoom = this.container.scale.x;
pos.x = pos.x * Settings.RATIO * zoom;
pos.y = -(pos.y * Settings.RATIO) * zoom;
var pos = this.me.getHeadPosition();
pos.x *= -Settings.RATIO * zoom;
pos.y *= -Settings.RATIO * zoom;
pos.x -= this.me.playerController.xyInput.x * Settings.STAGE_WIDTH / 4;
pos.y += this.me.playerController.xyInput.y * Settings.STAGE_HEIGHT / 4;