diff --git a/examples/game/test_physics.dart b/examples/game/test_physics.dart index ecadb2f6f0..059acfb8c5 100644 --- a/examples/game/test_physics.dart +++ b/examples/game/test_physics.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'package:flutter/animation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; @@ -52,7 +53,7 @@ class TestBed extends NodeWithSize { _physicsNode = new PhysicsNode(new Offset(0.0, 100.0)); _obstacle = new Sprite(_spriteSheet["ship.png"]); - _obstacle.position = new Point(532.0, 800.0); + _obstacle.position = new Point(512.0, 800.0); _obstacle.size = new Size(64.0, 64.0); _obstacle.physicsBody = new PhysicsBody( new PhysicsShapeCircle(Point.origin, 32.0), @@ -63,6 +64,13 @@ class TestBed extends NodeWithSize { _physicsNode.addChild(_obstacle); _physicsNode.addContactCallback(myCallback, "obstacle", "ship", PhysicsContactType.begin); + // Animate obstacle + ActionSequence seq = new ActionSequence([ + new ActionTween((a) => _obstacle.position = a, new Point(256.0, 800.0), new Point(768.0, 800.0), 1.0, easeInOut), + new ActionTween((a) => _obstacle.position = a, new Point(768.0, 800.0), new Point(256.0, 800.0), 1.0, easeInOut) + ]); + _obstacle.actions.run(new ActionRepeatForever(seq)); + addChild(_physicsNode); userInteractionEnabled = true;