LoginSignup
1
1

More than 5 years have passed since last update.

CreatejsでMovieClipをランダムなフレームから開始する方法

Posted at

ゲームなどでキャラクターのMovieClipをステージに複数配置した際、
それぞれのタイムラインをずらしたいときなどに使えるかもです。

ポイント

  1. mc.timeline.durationで、フレーム数になる
  2. CreateJSはフレームが0から始まる

// トータルフレーム数
var totalFrame:number = mc.timeline.duration;
// 全フレームの中からランダムなフレームを取得
var targetFrame:number = (Math.random() * totalFrame )>>0;
// 指定フレームからスタートする
mc.gotoAndPlay(targetFrame);

短縮版

mc.gotoAndPlay((Math.random() * mc.timeline.duration )>>0);

CreateJS では、MovieClip クラスに currentFrame プロパティはありますが、totalFrame プロパティは無いようです。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1