diff options
| author | Julie Lala <jules@okfoc.us> | 2014-04-29 03:47:32 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-04-29 03:47:32 -0400 |
| commit | c89f1107041a4ac8a513e4e2e7c1c3da984b1c59 (patch) | |
| tree | bbf94e2d7239193d8339e243d2489bb945cd2baf /assets/javascripts/mx/primitives/mx.image.js | |
| parent | aca59762480289d1cded7ebb53004b415d8d68ca (diff) | |
dragging between walls
Diffstat (limited to 'assets/javascripts/mx/primitives/mx.image.js')
| -rw-r--r-- | assets/javascripts/mx/primitives/mx.image.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/assets/javascripts/mx/primitives/mx.image.js b/assets/javascripts/mx/primitives/mx.image.js index 46422e5..4f9102a 100644 --- a/assets/javascripts/mx/primitives/mx.image.js +++ b/assets/javascripts/mx/primitives/mx.image.js @@ -29,17 +29,18 @@ MX.Image = MX.Object3D.extend({ loadTexture: function(ops){ var layer = this + layer.ops = defaults(ops, layer.ops) var image = new Image() image.onload = function(){ - layer.scale = ops.scale || 1 + layer.scale = layer.ops.scale || 1 layer.width = image.naturalWidth layer.height = image.naturalHeight - layer.x = ops.x || 0 - layer.y = (ops.y || 0) + layer.scale * layer.height/2 + 1 - layer.z = ops.z || 0 - layer.rotationX = ops.rotationX || 0 - layer.rotationY = ops.rotationY || 0 - layer.rotationZ = ops.rotationZ || 0 + layer.x = layer.ops.x || 0 + layer.y = (layer.ops.y || 0) + layer.scale * layer.height/2 + 1 + layer.z = layer.ops.z || 0 + layer.rotationX = layer.ops.rotationX || 0 + layer.rotationY = layer.ops.rotationY || 0 + layer.rotationZ = layer.ops.rotationZ || 0 layer.el.style.backgroundImage = "url(" + image.src + ")" layer.el.classList.add('image') layer.dirty = true @@ -47,6 +48,16 @@ MX.Image = MX.Object3D.extend({ } image.src = ops.src; }, + + move: function(ops){ + var layer = this + layer.ops = defaults(ops, layer.ops) + for (var i in ops) { + layer[i] = ops[i] + } + layer.dirty = true + layer.update() + }, toString: function(){ var params = "id src width height depth x y z rotationX rotationY rotationZ scale".split(" ") |
