stagexl 0.13.5+1 copy "stagexl: ^0.13.5+1" to clipboard
stagexl: ^0.13.5+1 copied to clipboard

outdatedDart 1 only

A fast and universal 2D rendering engine for HTML5 and Dart.

example/example.dart

library slot_machine;

import 'dart:async';
import 'dart:html' as html;
import 'package:stagexl/stagexl.dart';

Future main() async {

  // configure StageXL default options

  StageXL.stageOptions.renderEngine = RenderEngine.WebGL;
  StageXL.stageOptions.backgroundColor = Color.Black;
  StageXL.bitmapDataLoadOptions.webp = false;

  // init Stage and RenderLoop

  var canvas = html.querySelector('#stage');
  var stage = new Stage(canvas, width: 800, height: 600);
  var renderLoop = new RenderLoop();
  renderLoop.addStage(stage);

  var demoSprite = new Sprite();
  demoSprite.graphics.circle(0, 0, 100);
  demoSprite.graphics.fillColor(Color.White);

  var demoText = new TextField();
  demoText.defaultTextFormat = new TextFormat('Helvetica,Arial', 25, Color.Black);
  demoText.x = 0;
  demoText.y = 0;
  demoText.text = 'Test';
  demoSprite.addChild(demoText);

  //If scale is set to zero, the text field will be invisible until mouse click event
  demoSprite.scaleX = 0.1;
  demoSprite.scaleY = 0.1;
//  demoSprite.onMouseClick.listen((e) => demoText.text = demoText.text);

  stage.addChild(demoSprite);

//  stage.juggler.add(moveToAndScale(demoSprite, new Point(300, 300), 1));

  var tween = new Tween(demoText, 1.0)
    ..animate.scaleX.to(3.0)
    ..animate.scaleY.to(3.0)
    ..onComplete = () => demoText.text = demoText.text;


}

Animatable moveToAndScale(Sprite sprite, Point point, num scale, [var seconds, var transitionFunc]) {
  if(seconds == null) seconds = 2;
  if(transitionFunc == null) transitionFunc = Transition.easeInCubic;

  AnimationGroup ag = new AnimationGroup();

  Tween moveTween = new Tween(sprite, seconds, transitionFunc);
  moveTween.animate.x.to(point.x);
  moveTween.animate.y.to(point.y);
  ag.add(moveTween);

  Tween scaleTween = new Tween(sprite, seconds, transitionFunc);
  scaleTween.animate.scaleX.to(scale);
  scaleTween.animate.scaleY.to(scale);
  ag.add(scaleTween);

  return ag;
}
37
likes
0
pub points
56%
popularity

Publisher

unverified uploader

A fast and universal 2D rendering engine for HTML5 and Dart.

Homepage

Documentation

Documentation

License

unknown (license)

Dependencies

xml

More

Packages that depend on stagexl