|
@@ -1,4 +1,4 @@
|
|
|
-let test;
|
|
|
+let test, but, bu2;
|
|
|
|
|
|
class TestObject extends Object2D
|
|
|
{
|
|
@@ -7,8 +7,10 @@ class TestObject extends Object2D
|
|
|
this.position.y = 300;
|
|
|
this.position.x = 100;
|
|
|
|
|
|
- this.timer = new Timer("myTimer", 2);
|
|
|
- this.addChild(this.timer);
|
|
|
+ this.tween = new Tween("myTween");
|
|
|
+ this.tween.interpolateProperty(this.position, "x", PROPERTY_TYPE.NUMBER, this.position.x, 400, 2, TRANS_TYPE.LINEAR);
|
|
|
+ this.tween.interpolateProperty(this.position, "y", PROPERTY_TYPE.NUMBER, this.position.y, 100, 2, TRANS_TYPE.BOUNCE, EASE_TYPE.OUT);
|
|
|
+ this.addChild(this.tween);
|
|
|
}
|
|
|
|
|
|
_update(delta)
|
|
@@ -18,7 +20,7 @@ class TestObject extends Object2D
|
|
|
|
|
|
_draw(delta)
|
|
|
{
|
|
|
-
|
|
|
+ ellipse(0, 0, 20);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -26,7 +28,15 @@ class TestButton extends Button
|
|
|
{
|
|
|
_onMousePressed()
|
|
|
{
|
|
|
- this.getParent().getChildByName("myTimer").start();
|
|
|
+ if (this.name == "b1")
|
|
|
+ this.getParent().tween.start();
|
|
|
+ else if (this.name == "b2")
|
|
|
+ this.getParent().tween.stop();
|
|
|
+ else if (this.name == "b3")
|
|
|
+ this.getParent().tween.stopByIndex(0);
|
|
|
+ else if (this.name == "b4")
|
|
|
+ this.getParent().tween.startByIndex(0);
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -46,15 +56,24 @@ function setup()
|
|
|
textFont(AssetHandler.getP5FontByName("Lato"));
|
|
|
|
|
|
test = new TestObject("myTest");
|
|
|
- but = new TestButton("myTestButton", "play");
|
|
|
+ but = new TestButton("b1", "play");
|
|
|
but.setPosition(0, 200);
|
|
|
test.addChild(but);
|
|
|
+ but2 = new TestButton("b2", "stop");
|
|
|
+ but2.setPosition(0, 230);
|
|
|
+ test.addChild(but2);
|
|
|
+ but2 = new TestButton("b3", "stop1");
|
|
|
+ but2.setPosition(0, 260);
|
|
|
+ test.addChild(but2);
|
|
|
+ but2 = new TestButton("b4", "play1");
|
|
|
+ but2.setPosition(0, 290);
|
|
|
+ test.addChild(but2);
|
|
|
GameHandler.addRootObject(test);
|
|
|
- background(220);
|
|
|
}
|
|
|
|
|
|
function draw()
|
|
|
{
|
|
|
+ background(220);
|
|
|
GameHandler.update();
|
|
|
GameHandler.draw();
|
|
|
}
|