jojotyping01【phina.js】

自分のタイピングが遅くて正確性も低いので、イ○リートを中断してタイピングゲームを作ることに。


▷sceneの順

phina.main(function () {
  var app = GameApp({
    title: 'jojotyping',
    fontColor: 'black',
    startLabel: 'title',
    backgroundColor: 'white',

    scenes: [
      {
        className: 'SplashScene',
        label: 'splash',
        nextLabel: 'title',
      },
      {
        className: 'MyTitleScene',
        label: 'title',
        nextLabel: 'count',
      },
      {
        className: 'MyCountScene',
        label: 'count',
        nextLabel: 'main',
      },
      {
        className: 'MainScene',
        label: 'main',
        nextLabel: 'result',
      },
      {
        className: 'ResultScene',
        label: 'result',
        nextLabel: 'title',
      },
    ]
  });

 

▷タイトルのサイズ・位置変更

phina.define('MyTitleScene', {
  superClass: 'TitleScene',

  init: function (option) { //option 引数、GameAppの設定値(設定しなかった場合はデフォルト値)が入る
    this.superInit(option);
    // this = MainScene //クラスのインスタンス
    var titleLabel = this.children[0];
    titleLabel.fontSize = 100;
    titleLabel.y += 50;

    var touchLabel = this.children[1];
    touchLabel.fontSize = 50;
    touchLabel.y -= 140;

  },
});

 

▷デフォルトではカウントが始まる前に一瞬”Hello World”が見えてしまうので、その辺もカスタマイズ

phina.define('MyCountScene', {
  superClass: 'DisplayScene',
  /**
   * @constructor
   */
  init: function (options) {
    this.superInit(options);

    options = (options || {}).$safe(phina.game.CountScene.defaults);

    this.backgroundColor = options.backgroundColor;

    this.fromJSON({
      children: {
        label: {
          className: 'phina.display.Label',
          arguments: {
            fill: options.fontColor,
            fontSize: options.fontSize,
            stroke: false,
          },
          x: this.gridX.center(),
          y: this.gridY.center(),
          text: ""
        },
      }
    });

text: “”を追加。
カウントが始まる前にラベルのテキストを空文字列にして何も表示されないようにしている。

 

▷aを左に移動させる(画面外で消える)

phina.define('MainScene', {
  superClass: 'DisplayScene',

  init: function () {
    this.superInit();
    // this = MainSceneクラスのインスタンス

    var mojiLabel = Label({
      text: 'a',
      fill: 'black',
      fontSize: 30,
    }).addChildTo(this)   //mojiLabelをMainSceneの子供にする
      .setPosition(-50, this.gridY.center());
    mojiLabel.tweener
      .to({ x: this.width + 50 }, 4500)  //toは第一引数を目標にして値を変化(tweenerでのみ使える)
      .call(function () {
        mojiLabel.remove();   //callは第一引数の関数を呼び出す(tweenerでのみ使える)
      })
  },
});

 

コメントを残す

あなたのメールアドレスは公開されません。必須項目には印がついています *