From 6a816724c84baafbec0a121b5b1e9aa7b9521b6e Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 16:49:50 +0900 Subject: [PATCH 01/10] Accessory add method clone. --- src/accessory/accessory.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/accessory/accessory.js b/src/accessory/accessory.js index 8e6c21c1..ed0f6317 100644 --- a/src/accessory/accessory.js +++ b/src/accessory/accessory.js @@ -36,6 +36,10 @@ phina.namespace(function() { this.target.detach(this); this.target = null; }, + clone: function() { + return phina.accessory.Accessory(); + }, + }); phina.app.Element.prototype.$method('attach', function(accessory) { From 43c040d84cac4aaf6cdaff382c26f3381987bf19 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 16:51:16 +0900 Subject: [PATCH 02/10] fix Accessory clone. --- src/accessory/accessory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessory/accessory.js b/src/accessory/accessory.js index ed0f6317..d0bf72ab 100644 --- a/src/accessory/accessory.js +++ b/src/accessory/accessory.js @@ -37,7 +37,7 @@ phina.namespace(function() { this.target = null; }, clone: function() { - return phina.accessory.Accessory(); + return phina.accessory.Accessory(this.target); }, }); From b74509401c38d19a3b714d3db602f44805191870 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 17:19:08 +0900 Subject: [PATCH 03/10] fix Accessory clone --- src/accessory/accessory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessory/accessory.js b/src/accessory/accessory.js index d0bf72ab..f9f31891 100644 --- a/src/accessory/accessory.js +++ b/src/accessory/accessory.js @@ -37,7 +37,7 @@ phina.namespace(function() { this.target = null; }, clone: function() { - return phina.accessory.Accessory(this.target); + return phina.using(this.className)(this.target); }, }); From 2641c30f730bab5d6db5f9afd544a2ea5801f4f1 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 17:19:33 +0900 Subject: [PATCH 04/10] fix Flickable clone. --- src/accessory/flickable.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/accessory/flickable.js b/src/accessory/flickable.js index 989a2da7..97c0b20f 100644 --- a/src/accessory/flickable.js +++ b/src/accessory/flickable.js @@ -102,6 +102,14 @@ phina.namespace(function() { enable: function() { this._enable = true; }, + + clone: function() { + var flickable = phina.accessory.Flickable(this.target); + flickable.friction = this.friction; + flickable.horizontal = this.horizontal; + flickable.vertical = this.vertical; + return flickable; + }, }); From 3233d39a96d44e87aab6689ff3a6450c5d0c11d5 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 17:26:48 +0900 Subject: [PATCH 05/10] fix Flickable clone test. --- test/game/src/accessory.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/game/src/accessory.js b/test/game/src/accessory.js index a2e68ddd..b0c8d6b5 100644 --- a/test/game/src/accessory.js +++ b/test/game/src/accessory.js @@ -244,6 +244,24 @@ th.describe("accessory.Flickable", function() { label.text = angle; }; }); + + th.it('clone', function() { + + var shape = phina.display.CircleShape().addChildTo(this); + shape.setPosition(160, 480); + shape.flickable.enable(); + + shape.flickable.horizontal = true; + shape.flickable.vertical = false; + + var flickable = shape.flickable.clone(); + + var shape = phina.display.CircleShape().addChildTo(this); + shape.setPosition(480, 480); + flickable.enable(); + flickable.attachTo(shape); + + }); }); From 69532ac6d326d4fd50bc569f638deac4aa260aae Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 17:32:48 +0900 Subject: [PATCH 06/10] fix Physical clone. --- src/accessory/physical.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/accessory/physical.js b/src/accessory/physical.js index 937c3bf3..cbbd4e29 100644 --- a/src/accessory/physical.js +++ b/src/accessory/physical.js @@ -59,6 +59,12 @@ phina.namespace(function() { this.friction = fr; return this; }, + + clone: function() { + return phina.accessory.Physical(this.target) + .setFriction(this.friction) + .setGravity(this.gravity.x, this.gravity.y); + }, }); phina.app.Element.prototype.getter('physical', function() { From 319203fc42d78b4de21010acf70ab861c174fe35 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 18:02:20 +0900 Subject: [PATCH 07/10] fix tweener clone. --- src/accessory/tweener.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/accessory/tweener.js b/src/accessory/tweener.js index 311e8a43..9f498bc9 100644 --- a/src/accessory/tweener.js +++ b/src/accessory/tweener.js @@ -212,6 +212,16 @@ phina.namespace(function() { this._init(); return this; }, + + clone: function() { + var tweener = Tweener(this.target); + tweener._tasks = this.tasks.clone(); + tweener._index = this._index; + tweener.playing = this.playing; + tweener._loop = this._loop; + tweener.updateType = this.updateType; + return tweener; + }, fromJSON: function(json) { if (json.loop !== undefined) { From a6990658ab4cd6dfa31b909996236e267f0d4708 Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 18:03:57 +0900 Subject: [PATCH 08/10] fix semicolon. --- test/game/src/accessory.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/game/src/accessory.js b/test/game/src/accessory.js index b0c8d6b5..96aa79af 100644 --- a/test/game/src/accessory.js +++ b/test/game/src/accessory.js @@ -4,7 +4,7 @@ th.describe("accessory.Tweener", function() { var shape = phina.display.CircleShape().addChildTo(this); var tweener = phina.accessory.Tweener().attachTo(shape); tweener - .to({x:320, y:480}, 1000) + .to({x:320, y:480}, 1000); }); th.it('to', function() { @@ -12,7 +12,7 @@ th.describe("accessory.Tweener", function() { var tweener = phina.accessory.Tweener().attachTo(shape); tweener .to({x:320, y:480}, 1000) - .to({scaleX:4,scaleY:4, rotation:360}, 1000) + .to({scaleX:4,scaleY:4, rotation:360}, 1000); }); th.it('by', function() { @@ -21,7 +21,7 @@ th.describe("accessory.Tweener", function() { tweener .to({x:320, y:480}, 1000) .by({x:100, y:100}, 1000) - .to({scaleX:4,scaleY:4, rotation:360}, 1000) + .to({scaleX:4,scaleY:4, rotation:360}, 1000); }); th.it('from', function() { @@ -29,7 +29,7 @@ th.describe("accessory.Tweener", function() { shape.position.set(320, 480); var tweener = phina.accessory.Tweener().attachTo(shape); tweener - .from({scaleX:4,scaleY:4, rotation:360}, 1000) + .from({scaleX:4,scaleY:4, rotation:360}, 1000); }); th.it('wait', function() { @@ -38,7 +38,7 @@ th.describe("accessory.Tweener", function() { tweener .to({x:320, y:480}, 1000) .wait(1000) - .to({scaleX:4,scaleY:4, rotation:360}, 1000) + .to({scaleX:4,scaleY:4, rotation:360}, 1000); }); th.it('call', function() { @@ -52,7 +52,7 @@ th.describe("accessory.Tweener", function() { .to({scaleX:4,scaleY:4, rotation:360}, 1000) .call(function() { shape.style.color = 'blue'; - }) + }); }); th.it('set', function() { @@ -64,7 +64,7 @@ th.describe("accessory.Tweener", function() { .set({scaleX:4, scaleY:4}) .call(function() { shape.fill = 'green'; - }) + }); }); th.it('play', function() { @@ -87,7 +87,7 @@ th.describe("accessory.Tweener", function() { .to({x:320, y:480}, 1000) .call(function() { this.rewind(); - }) + }); }); th.it('yoyo', function() { @@ -98,7 +98,7 @@ th.describe("accessory.Tweener", function() { .to({x:320+150, y:480}, 1000) .call(function() { this.yoyo(); - }) + }); }); th.it('loop', function() { From 90d6624eb1316385a8c719b945ab9308d026165d Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 18:07:14 +0900 Subject: [PATCH 09/10] bug fix tweener clone. --- src/accessory/tweener.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/accessory/tweener.js b/src/accessory/tweener.js index 9f498bc9..abdd13ad 100644 --- a/src/accessory/tweener.js +++ b/src/accessory/tweener.js @@ -215,7 +215,7 @@ phina.namespace(function() { clone: function() { var tweener = Tweener(this.target); - tweener._tasks = this.tasks.clone(); + tweener._tasks = this._tasks.clone(); tweener._index = this._index; tweener.playing = this.playing; tweener._loop = this._loop; From fa178529a24066a2368bb6534297681c3ffd499e Mon Sep 17 00:00:00 2001 From: simiraaaa Date: Sat, 2 Jul 2016 18:07:29 +0900 Subject: [PATCH 10/10] fix tweener clone test. --- test/game/src/accessory.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/game/src/accessory.js b/test/game/src/accessory.js index 96aa79af..f7e4e433 100644 --- a/test/game/src/accessory.js +++ b/test/game/src/accessory.js @@ -124,7 +124,21 @@ th.describe("accessory.Tweener", function() { ] }); }); - + + th.it('clone', function() { + var shape = phina.display.RectangleShape().addChildTo(this); + var tweener = phina.accessory.Tweener().attachTo(shape); + tweener + .to({x:320, y:480}, 1000) + .to({scaleX:4,scaleY:4, rotation:360}, 1000); + var tweener2 = tweener.clone(); + + var shape = phina.display.RectangleShape({ + x: 640, + y: 960, + }).addChildTo(this); + shape.attach(tweener2); + }); });