Last active
January 24, 2023 22:13
-
-
Save duksis/fc211c09ee2acead32c0 to your computer and use it in GitHub Desktop.
Pixi.js basic example with a rotating Honeypot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var renderer = PIXI.autoDetectRenderer(750, 600,{backgroundColor : 0x1099bb}); | |
document.getElementById("rotating-honeypot").appendChild(renderer.view); | |
// create the root of the scene graph | |
var stage = new PIXI.Container(); | |
// create a texture from an image path | |
var texture = PIXI.Texture.fromImage('../assets/images/mascot.png'); | |
// create a new Sprite using the texture | |
var mascot = new PIXI.Sprite(texture); | |
// center the sprite's anchor point | |
mascot.anchor.x = 0.5; | |
mascot.anchor.y = 0.5; | |
// move the sprite to the center of the screen | |
mascot.position.x = 360; | |
mascot.position.y = 300; | |
stage.addChild(mascot); | |
// start animating | |
animate(); | |
function animate() { | |
requestAnimationFrame(animate); | |
// just for fun, let's rotate mr Honeypot a little | |
mascot.rotation += 0.05; | |
// render the container | |
renderer.render(stage); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment