implemented gameobject for tiles and doll

This commit is contained in:
jeena 2013-12-23 02:39:05 +01:00
parent fe0d4a66e2
commit d51c705c1c
15 changed files with 221 additions and 326 deletions

View file

@ -1,11 +1,11 @@
define([
"Game/Core/GameObjects/GameObject"
"Game/Core/GameObjects/GameObject",
"Lib/Utilities/Exception"
],
function(Parent) {
function (Parent, Exception) {
function GameObject(physicsEngine, view) {
this.view = view;
function GameObject(physicsEngine) {
Parent.call(this, physicsEngine);
this.createMesh();
this.render();
@ -23,7 +23,7 @@ function(Parent) {
}
GameObject.prototype.createMesh = function() {
throw new Exception('Abstract method GameObject.getMesh not overwritten');
throw new Exception('Abstract method GameObject.createMesh not overwritten');
};
return GameObject;

View file

@ -1,12 +1,13 @@
define([
"Game/Core/GameObjects/Tile",
"Game/Config/Settings"
"Game/Config/Settings",
"Game/Core/NotificationCenter"
],
function (Parent, Settings) {
function (Parent, Settings, NotificationCenter) {
function Tile(physicsEngine, view, options) {
Parent.call(this, physicsEngine, view, options);
function Tile(physicsEngine, options) {
Parent.call(this, physicsEngine, options);
}
Tile.prototype = Object.create(Parent.prototype);
@ -19,28 +20,32 @@ function (Parent, Settings) {
+ Settings.GRAPHICS_SUBPATH_TILES
+ material + '/'
+ this.options.s + ''
+ this.options.r + '.gif';
+ (this.options.r || 0) + '.gif';
var callback = function(mesh) {
self.mesh = mesh;
self.view.addMesh(mesh);
NotificationCenter.trigger("view/addMesh", mesh);
}
this.view.createMesh(
Settings.TILE_SIZE,
Settings.TILE_SIZE,
0,
0,
imgPath,
callback
);
NotificationCenter.trigger("view/createMesh",
Settings.TILE_SIZE,
Settings.TILE_SIZE,
0,
0,
imgPath,
callback
);
};
Tile.prototype.render = function() {
this.view.updateMesh(this.mesh, {
x: this.options.x * Settings.TILE_SIZE,
y: this.options.y * Settings.TILE_SIZE,
})
NotificationCenter.trigger("view/updateMesh",
this.mesh,
{
x: this.options.x * Settings.TILE_SIZE,
y: this.options.y * Settings.TILE_SIZE,
}
);
}
return Tile;