world
This commit is contained in:
44
sprite.cm
44
sprite.cm
@@ -2,27 +2,9 @@
|
||||
//
|
||||
// Returns a function that creates sprite instances via meme()
|
||||
|
||||
var dirty = {}
|
||||
|
||||
var sprite = {
|
||||
type: 'sprite',
|
||||
pos: null,
|
||||
layer: 0,
|
||||
image: null,
|
||||
width: 1,
|
||||
height: 1,
|
||||
anchor_x: 0,
|
||||
anchor_y: 0,
|
||||
scale_x: 1,
|
||||
scale_y: 1,
|
||||
color: null,
|
||||
uv_rect: null,
|
||||
slice: null,
|
||||
tile: null,
|
||||
material: null,
|
||||
opacity: 1,
|
||||
|
||||
// Dirty tracking
|
||||
dirty: 7, // DIRTY.ALL
|
||||
|
||||
// Setters that mark dirty
|
||||
set_pos: function(x, y) {
|
||||
if (!this.pos) this.pos = {x: 0, y: 0}
|
||||
@@ -79,5 +61,25 @@ stone(sprite)
|
||||
|
||||
// Factory function
|
||||
return function(props) {
|
||||
return meme(sprite, props)
|
||||
var defaults = {
|
||||
pos: {x:0,y:0},
|
||||
layer: 0,
|
||||
image: null,
|
||||
width: 1,
|
||||
height: 1,
|
||||
anchor_x: 0,
|
||||
anchor_y: 0,
|
||||
scale_x: 1,
|
||||
scale_y: 1,
|
||||
color: null,
|
||||
uv_rect: null,
|
||||
slice: null,
|
||||
tile: null,
|
||||
material: null,
|
||||
opacity: 1,
|
||||
}
|
||||
|
||||
var newsprite = meme(sprite, [defaults,props])
|
||||
newsprite[dirty] = 7
|
||||
return newsprite
|
||||
}
|
||||
Reference in New Issue
Block a user