mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
added background, still needs parallax style scrolling though! - fixes #89
This commit is contained in:
parent
a58beb58d1
commit
1a71fa38f9
8 changed files with 47 additions and 6 deletions
|
|
@ -40,7 +40,8 @@ function (Parent, Settings) {
|
||||||
paths.push(texturePath);
|
paths.push(texturePath);
|
||||||
};
|
};
|
||||||
|
|
||||||
// FIXME: Get background image
|
var background = this.getLayer(levelData, "background");
|
||||||
|
paths.push(Settings.MAPS_PATH + background.image);
|
||||||
|
|
||||||
return paths;
|
return paths;
|
||||||
|
|
||||||
|
|
|
||||||
20
app/Game/Client/View/Mesh.js
Normal file
20
app/Game/Client/View/Mesh.js
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
define([
|
||||||
|
'Game/Config/Settings',
|
||||||
|
'Lib/Utilities/NotificationCenter',
|
||||||
|
"Lib/Vendor/Stats",
|
||||||
|
"Lib/Vendor/Screenfull"
|
||||||
|
],
|
||||||
|
|
||||||
|
function (Settings, Nc, Stats, Screenfull) {
|
||||||
|
|
||||||
|
function Mesh() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Mesh.prototype.render = function() {
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
return Mesh;
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -117,6 +117,7 @@ function (Parent, DomController, PIXI, ColorRangeReplaceFilter, Settings, Nc, Ex
|
||||||
if (options.x) mesh.position.x = options.x;
|
if (options.x) mesh.position.x = options.x;
|
||||||
if (options.y) mesh.position.y = options.y;
|
if (options.y) mesh.position.y = options.y;
|
||||||
if (options.rotation) mesh.rotation = options.rotation;
|
if (options.rotation) mesh.rotation = options.rotation;
|
||||||
|
if (options.alpha) mesh.alpha = options.alpha;
|
||||||
if (options.width) mesh.width = options.width;
|
if (options.width) mesh.width = options.width;
|
||||||
if (options.height) mesh.height = options.height;
|
if (options.height) mesh.height = options.height;
|
||||||
if (options.xScale) mesh.width = Math.abs(mesh.width) * options.xScale;
|
if (options.xScale) mesh.width = Math.abs(mesh.width) * options.xScale;
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ define([
|
||||||
var path = Settings.MAPS_PATH + uid + ".json"
|
var path = Settings.MAPS_PATH + uid + ".json"
|
||||||
this.loadLevelDataFromPath(path, function(levelData) {
|
this.loadLevelDataFromPath(path, function(levelData) {
|
||||||
self.levelData = levelData;
|
self.levelData = levelData;
|
||||||
|
self.addBackground();
|
||||||
self.createTiles();
|
self.createTiles();
|
||||||
self.createItems();
|
self.createItems();
|
||||||
self.isLoaded = true;
|
self.isLoaded = true;
|
||||||
|
|
@ -97,6 +98,10 @@ define([
|
||||||
//this.gameObjects.animated.push(item);
|
//this.gameObjects.animated.push(item);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Extended by TiledLevel
|
||||||
|
Level.prototype.addBackground = function() {
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return Level;
|
return Level;
|
||||||
|
|
|
||||||
|
|
@ -5,12 +5,13 @@ define([
|
||||||
"Lib/Vendor/Box2D",
|
"Lib/Vendor/Box2D",
|
||||||
"Lib/Utilities/Options",
|
"Lib/Utilities/Options",
|
||||||
"Lib/Utilities/Exception",
|
"Lib/Utilities/Exception",
|
||||||
|
"Lib/Utilities/NotificationCenter",
|
||||||
"Game/" + GLOBALS.context + "/Collision/Detector",
|
"Game/" + GLOBALS.context + "/Collision/Detector",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
"Game/" + GLOBALS.context + "/GameObjects/Tile",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
"Game/" + GLOBALS.context + "/GameObjects/Item",
|
||||||
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
"Game/" + GLOBALS.context + "/GameObjects/Items/Skateboard",
|
||||||
|
|
||||||
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, CollisionDetector, Tile, Item, Skateboard) {
|
], function (Parent, Settings, ItemSettings, Box2D, Options, Exception, Nc, CollisionDetector, Tile, Item, Skateboard) {
|
||||||
|
|
||||||
// Public
|
// Public
|
||||||
function TiledLevel (path, engine) {
|
function TiledLevel (path, engine) {
|
||||||
|
|
@ -75,6 +76,20 @@ define([
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
TiledLevel.prototype.addBackground = function(path) {
|
||||||
|
|
||||||
|
var texturePath = Settings.GRAPHICS_PATH + "Backgrounds/starnight.png";
|
||||||
|
var callback = function (mesh) {
|
||||||
|
Nc.trigger(Nc.ns.client.view.mesh.add, mesh, 0); // FIXME: add at z layer -1 or so
|
||||||
|
}
|
||||||
|
Nc.trigger(Nc.ns.client.view.mesh.create, texturePath, callback, {
|
||||||
|
width: 4000,
|
||||||
|
height: 2959,
|
||||||
|
x: -(4000 - Settings.STAGE_WIDTH) / 2,
|
||||||
|
y: -(2959 + Settings.STAGE_HEIGHT + 700) / 2
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
TiledLevel.prototype.gatherOptions = function(tiledObject) {
|
TiledLevel.prototype.gatherOptions = function(tiledObject) {
|
||||||
var options = {};
|
var options = {};
|
||||||
|
|
||||||
|
|
@ -138,7 +153,6 @@ define([
|
||||||
x: object.x / Settings.TILE_RATIO,
|
x: object.x / Settings.TILE_RATIO,
|
||||||
y: object.y / Settings.TILE_RATIO
|
y: object.y / Settings.TILE_RATIO
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
BIN
static/img/Backgrounds/starnight.png
Normal file
BIN
static/img/Backgrounds/starnight.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.7 MiB |
|
|
@ -3,7 +3,7 @@
|
||||||
"layers":[
|
"layers":[
|
||||||
{
|
{
|
||||||
"height":0,
|
"height":0,
|
||||||
"image":"..\/..\/img\/Backgrounds\/londonatnight.jpg",
|
"image":"..\/..\/img\/Backgrounds\/starnight.png",
|
||||||
"name":"background",
|
"name":"background",
|
||||||
"opacity":1,
|
"opacity":1,
|
||||||
"type":"imagelayer",
|
"type":"imagelayer",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue