tiled only Y option
This commit is contained in:
parent
b43b67ecac
commit
8ea015eee0
@ -1,6 +1,7 @@
|
|||||||
**/.git
|
**/.git
|
||||||
**/node_modules
|
**/node_modules
|
||||||
**/dist
|
**/dist
|
||||||
|
test/js/engine.js
|
||||||
|
|
||||||
*.html
|
*.html
|
||||||
*.css
|
*.css
|
||||||
|
@ -95,8 +95,10 @@ export class Sprite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class TiledSprite extends Sprite {
|
export class TiledSprite extends Sprite {
|
||||||
constructor(src = null, x, y) {
|
constructor(src = null, x, y, only = null) {
|
||||||
super(src, x, y);
|
super(src, x, y);
|
||||||
|
|
||||||
|
this.only = only;
|
||||||
}
|
}
|
||||||
|
|
||||||
draw(context, debug = false) {
|
draw(context, debug = false) {
|
||||||
@ -126,16 +128,24 @@ export class TiledSprite extends Sprite {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.drawImage(
|
switch (this.only) {
|
||||||
this.image(),
|
case 'y':
|
||||||
this.x - this.image().width * ix,
|
context.drawImage(this.image(), this.x, this.y - this.image().height * iy);
|
||||||
this.y - this.image().height * iy
|
break;
|
||||||
);
|
case null:
|
||||||
|
default:
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x + this.image().width * ix,
|
this.x + this.image().width * ix,
|
||||||
this.y - this.image().height * iy
|
this.y - this.image().height * iy
|
||||||
);
|
);
|
||||||
|
context.drawImage(
|
||||||
|
this.image(),
|
||||||
|
this.x - this.image().width * ix,
|
||||||
|
this.y - this.image().height * iy
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,16 +159,24 @@ export class TiledSprite extends Sprite {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.drawImage(
|
switch (this.only) {
|
||||||
this.image(),
|
case 'y':
|
||||||
this.x - this.image().width * ix,
|
context.drawImage(this.image(), this.x, this.y + this.image().height * iy);
|
||||||
this.y + this.image().height * iy
|
break;
|
||||||
);
|
case null:
|
||||||
|
default:
|
||||||
context.drawImage(
|
context.drawImage(
|
||||||
this.image(),
|
this.image(),
|
||||||
this.x + this.image().width * ix,
|
this.x + this.image().width * ix,
|
||||||
this.y + this.image().height * iy
|
this.y + this.image().height * iy
|
||||||
);
|
);
|
||||||
|
context.drawImage(
|
||||||
|
this.image(),
|
||||||
|
this.x - this.image().width * ix,
|
||||||
|
this.y + this.image().height * iy
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user