0

私はrequirejsを使用してKineticにロードしています。スプライトを作成してキャンバスにロードする簡単なスクリプトがあります。1 フレームのデフォルトのアイドル状態でスプライトをロードします。

require(['libraries/kinetic'], function(Kinetic){

  console.log('Initializing....');

  var stage  = new Kinetic.Stage({
    container : 'canvas',
    width     : 578,
    height    : 200
  }),
  layer      = new Kinetic.Layer(),
  animations = {
    idleRight: [{
      x      : 343,
      y      : 2,
      width  : 26,
      height : 58
    }]
  },
  imageObj     = new Image();
  imageObj.src = '/assets/images/billy.png';

  imageObj.onload = function() {

    var billy = new Kinetic.Sprite({
      x          : 25,
      y          : 25,
      image      : imageObj,
      animation  : 'idleRight',
      animations : animations,
      frameRate  : 7
    });

    // add the shape to the layer
    layer.add(billy);

    // add the layer to the stage
    stage.add(layer);

    // start sprite animation
    billy.start();

    console.log('Done.');

  }; // .onload

}); // require

キネティックが適切にロードされるように、require に shim 構成を使用しています。

requirejs.config({
    baseUrl: '/assets/js',
    shim: {
        'libraries/kinetic' : {
          exports : 'Kinetic'
        },
    }
});

何を試しても、スプライト/画像が表示されません! どんな助けでも大歓迎です!

テストスプライトとしてGoogleのこの画像を使用しています:

http://www.nes-snes-sprites.com/ImagesSheet/SuperDoubleDragonSheet2.gif
4

1 に答える 1

0

domeReady requirejs モジュールを使用して終了し、以下のようにロードしました。

require(['libraries/require/domReady!',
        'libraries/kinetic'], function(document, Kinetic){... etc
于 2012-12-12T04:34:18.177 に答える