HTML and CSS Reference
In-Depth Information
get : function(id) { return this.byId[id] || this.byName[id] || null; },
apply : function(names, obj) {
for (var i=0;i<names.length;i++) {
var t = this.byName[names[i]]
for (var key in obj) if (obj.hasOwnProperty(key)) t[key] = obj[key];
}
},
addMany : function(Type, names, obj) {
for (var i=0;i<names.length;i++)
this.add(new Type(names[i], obj))
}
}}
List of Sprites
Let the side of a square tile be 32 = 2 5 pixels. Before the editor starts, you need to load all necessary sprites; otherwise,
the first attempt to paint the window will fail:
var TILE_SIZE = 32, TILE_SIZE_BITS = 5;
The format of objects added to SpriteList is as follows:
function Sprite(name, source, x, y) {
this.name = name; this.source = source;this.x = x;this.y = y;
}
Sprite.prototype = {}
var SpriteList = function() {
this.byId = []
this.byName = {}
}
Later, you will use sprite collections for generating tiles, depending on the tile types, and you will generate the
proper sprite names, depending on the type and name of each tile (see the section “Basic Tileset Configuration”).
addSpriteSheet makes a list of sprites from a graphic file and a list of sprite names:
SpriteList.prototype = {
loaded: 0, total: 0,
onComplete: null,
add: function(sprite) {
sprite.id = this.byId.length
this.byId.push(sprite);
this.byName[sprite.name] = sprite;
},
 
Search WWH ::




Custom Search