mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed problems with first world update
This commit is contained in:
parent
283a1ef48b
commit
93e8133c89
13 changed files with 353 additions and 166 deletions
53
app/Game/Client/GameObjects/Item.js
Normal file
53
app/Game/Client/GameObjects/Item.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
define([
|
||||
"Game/Core/GameObjects/Item",
|
||||
"Game/Config/Settings",
|
||||
"Game/Core/NotificationCenter"
|
||||
],
|
||||
|
||||
function (Parent, Settings, NotificationCenter) {
|
||||
|
||||
function Item(physicsEngine, uid, options) {
|
||||
Parent.call(this, physicsEngine, uid, options);
|
||||
}
|
||||
|
||||
Item.prototype = Object.create(Parent.prototype);
|
||||
|
||||
Item.prototype.createMesh = function() {
|
||||
var self = this;
|
||||
|
||||
var texturePath = Settings.GRAPHICS_PATH
|
||||
+ Settings.GRAPHICS_SUBPATH_ITEMS
|
||||
+ this.options.category + '/'
|
||||
+ this.options.image;
|
||||
|
||||
var callback = function(mesh) {
|
||||
self.mesh = mesh;
|
||||
NotificationCenter.trigger("view/addMesh", mesh);
|
||||
}
|
||||
|
||||
NotificationCenter.trigger("view/createMesh",
|
||||
texturePath,
|
||||
callback,
|
||||
{
|
||||
width: this.options.width,
|
||||
height: this.options.height,
|
||||
pivot: "mb"
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
Item.prototype.render = function() {
|
||||
|
||||
NotificationCenter.trigger("view/updateMesh",
|
||||
this.mesh,
|
||||
{
|
||||
x: this.body.GetPosition().x * Settings.RATIO,
|
||||
y: this.body.GetPosition().y * Settings.RATIO,
|
||||
rotation: this.body.GetAngle()
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return Item;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue