本文整理汇总了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();
});
});
示例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();
});
});
示例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();
});
});
示例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();
});
});
示例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();
});
});
示例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();
});
});
示例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();
});
});
示例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();
});
});