-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpixi.html
66 lines (53 loc) · 1.72 KB
/
pixi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Hello World</title>
</head>
<script src="pixi/pixi.min.js"></script>
<body>
<script type="text/javascript">
//Aliases
let Application = PIXI.Application,
loader = PIXI.Loader.shared,
resources = PIXI.loader.resources,
Sprite = PIXI.Sprite;
//Create a Pixi Application
let app = new Application({
width: 256,
height: 256,
antialias: true,
transparent: false,
resolution: 1
}
);
//Making the canvas fullscreen
let border = 10;
app.renderer.view.style.position = "absolute";
app.renderer.view.style.display = "block";
app.renderer.autoResize = true;
app.renderer.resize(window.innerWidth-border, window.innerHeight-border);
//Add the canvas that Pixi automatically created for you to the HTML document
document.body.appendChild(app.view);
//load an image and run the `setup` function when it's done
loader
.add("assets/images/cat.png")
.load(setup);
var textureButton = PIXI.Texture.fromImage("assets/images/cat.png");
var button = new Sprite(textureButton);
button.buttonMode = true;
button.anchor.set(0.5);
button.position.x = 75;
button.position.y = 75;
button.interactive = true;
app.stage.addChild(button);
//This `setup` function will run when the image has loaded
function setup() {
//Create the cat sprite
let cat = new Sprite(resources["assets/images/cat.png"].texture);
//Add the cat to the stage
app.stage.addChild(cat);
}
</script>
</body>
</html>