當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript excalibur-jasmine.ensureImagesLoaded函數代碼示例

本文整理匯總了TypeScript中excalibur-jasmine.ensureImagesLoaded函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript ensureImagesLoaded函數的具體用法?TypeScript ensureImagesLoaded怎麽用?TypeScript ensureImagesLoaded使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ensureImagesLoaded函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: expect

    gif.load().then(() => {
      expect(gif).toBeDefined();

      const spriteFrame: ex.Sprite = gif.asSprite();
      expect(spriteFrame).toBeDefined();
      expect(spriteFrame.drawHeight).toBe(100);
      expect(spriteFrame.drawWidth).toBe(100);

      let sprite: ex.Sprite = gif.asSprite();
      expect(gif.isLoaded()).toBe(true);
      sprite.draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/GifSpec/frame1.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
      engine.ctx.clearRect(0, 0, engine.canvas.width, engine.canvas.height);

      sprite = gif.asSprite(1);
      expect(gif.isLoaded()).toBe(true);
      sprite.draw(engine.ctx, 0, 0);
      ensureImagesLoaded(engine.canvas, 'src/spec/images/GifSpec/frame2.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:26,代碼來源:GifSpec.ts

示例2: ensureImagesLoaded

    texture.load().then(() => {
      const sf = new ex.SpriteFont({
        image: texture,
        alphabet: '0123456789abcdefghijklmnopqrstuvwxyz,!\'&."?- ',
        caseInsensitive: true,
        columns: 16,
        rows: 3,
        spWidth: 16,
        spHeight: 16
      });

      const sprites = sf.getTextSprites();

      sprites['0'].draw(engine.ctx, 0, 0);
      sprites['4'].draw(engine.ctx, 16, 0);
      sprites['9'].draw(engine.ctx, 2 * 16, 0);
      // tslint:disable-next-line:no-string-literal
      sprites['a'].draw(engine.ctx, 3 * 16, 0);
      // tslint:disable-next-line:no-string-literal
      sprites['q'].draw(engine.ctx, 4 * 16, 0);
      // tslint:disable-next-line:no-string-literal
      sprites['z'].draw(engine.ctx, 5 * 16, 0);
      sprites['&'].draw(engine.ctx, 1 * 16, 16);
      sprites['.'].draw(engine.ctx, 2 * 16, 16);
      sprites['"'].draw(engine.ctx, 3 * 16, 16);
      sprites['?'].draw(engine.ctx, 4 * 16, 16);
      sprites['-'].draw(engine.ctx, 5 * 16, 16);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteFontSpec/IndividualSprites.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:33,代碼來源:SpriteFontSpec.ts

示例3: ensureImagesLoaded

 actor.on('postdraw', (ev: ex.PostDrawEvent) => {
   engine.stop();
   ensureImagesLoaded(engine.canvas, 'src/spec/images/ScaleSpec/scale.png').then(([canvas, image]) => {
     expect(canvas).toEqualImage(image);
     done();
   });
 });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:7,代碼來源:ScaleSpec.ts

示例4: expect

    texture.load().then(() => {
      let ss = new ex.SpriteSheet({
        image: texture,
        columns: 3,
        rows: 2,
        spWidth: 32,
        spHeight: 32,
        spacing: 1
      });

      expect(ss.image.isLoaded());
      expect(ss.columns).toBe(3);
      expect(ss.rows).toBe(2);
      expect(ss.spWidth).toBe(32);
      expect(ss.spHeight).toBe(32);

      expect(ss.sprites.length).toBe(6);

      ss.getSprite(2).draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSheetSpec/SpriteSheetSpacing2.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
開發者ID:agrgic16,項目名稱:Excalibur,代碼行數:25,代碼來源:SpriteSheetSpec.ts

示例5: expect

    texture.load().then(() => {
      const sprite = new ex.Sprite({
        image: texture,
        x: 0,
        y: 0,
        width: 62,
        height: 64,
        rotation: 0,
        anchor: new ex.Vector(0.0, 0.0),
        scale: new ex.Vector(1, 1),
        flipVertical: false,
        flipHorizontal: false
      });

      expect(texture.isLoaded()).toBe(true);
      expect(sprite.x).toBe(0);
      expect(sprite.y).toBe(0);
      expect(sprite.width).toBe(62);
      expect(sprite.height).toBe(64);
      expect(sprite.rotation).toBe(0);
      expect(sprite.anchor.x).toBe(0.0);
      expect(sprite.anchor.y).toBe(0.0);
      expect(sprite.scale.x).toBe(1);
      expect(sprite.scale.y).toBe(1);
      expect(sprite.flipHorizontal).toBe(false);
      expect(sprite.flipVertical).toBe(false);

      sprite.draw(engine.ctx, 0, 0);

      ensureImagesLoaded(engine.canvas, 'src/spec/images/SpriteSpec/icon.png').then(([canvas, image]) => {
        expect(canvas).toEqualImage(image);
        done();
      });
    });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:34,代碼來源:SpriteSpec.ts

示例6: ensureImagesLoaded

      uiActor.on('postdraw', (ev: ex.PostDrawEvent) => {
        game.stop();

        ensureImagesLoaded(game.canvas, 'src/spec/images/UIActorSpec/emptyctor.png').then(([canvas, image]) => {
          expect(canvas).toEqualImage(image);
          done();
        });
      });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:8,代碼來源:UIActorSpec.ts

示例7: it

 it('can draw a 2d image', (done) => {
   jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
   var drawer = new ex.PerlinDrawer2D(generator);
   var image = drawer.image(150, 150);
   ensureImagesLoaded(image, 'src/spec/images/PerlinSpec/perlin.png').then(([canvas, image]) => {
     expect(canvas).toEqualImage(image);
     done();
   });
 });
開發者ID:agrgic16,項目名稱:Excalibur,代碼行數:9,代碼來源:PerlinSpec.ts

示例8: it

  it('is not drawn on the screen when not visible', (done) => {
    uiActor.visible = false;
    scene.add(uiActor);
    scene.draw(engine.ctx, 100);

    ensureImagesLoaded(engine.canvas, 'src/spec/images/UIActorSpec/actordoesnotdraw.png').then(([canvas, image]) => {
      expect(canvas).toEqualImage(image);
      done();
    });
  });
開發者ID:excaliburjs,項目名稱:Excalibur,代碼行數:10,代碼來源:UIActorSpec.ts


注:本文中的excalibur-jasmine.ensureImagesLoaded函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。