Pixi.js template

This commit is contained in:
Alexander Popov 2022-10-06 17:23:33 +03:00
parent c5072ab5d3
commit 7db0e02051
Signed by: iiiypuk
GPG Key ID: D8C9B59A9F04A70C
2 changed files with 37 additions and 0 deletions

View File

@ -0,0 +1,22 @@
window.onload = function() {
let app = new PIXI.Application({ width: 640, height: 360 });
document.body.appendChild(app.view);
let elapsed = 0.0;
let spriteSkull = PIXI.Sprite.from('/assets/skull.png');
let spriteSpiderWeb = PIXI.Sprite.from('/assets/spider-web.png');
spriteSpiderWeb.y = (360 / 2) - (spriteSpiderWeb.height / 2)
app.stage.addChild(spriteSkull);
app.stage.addChild(spriteSpiderWeb);
app.ticker.add((delta) => {
elapsed += delta;
spriteSkull.x = 100.0 + Math.cos(elapsed/50.0) * 100.0;
});
app.ticker.add((delta) => {
elapsed += delta;
spriteSpiderWeb.x = 100.0 + Math.cos(elapsed / 50.0) * 100.0;
});
}

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>pixi - template</title>
<script type="text/javascript" src="/pixi.js"></script>
</head>
<body>
<div class="container">
<!-- -->
</div>
<script type="text/javascript" src="app.js"></script>
</body>
</html>