git init
npm install pixi.js
index.html์์ ์๋ ์ถ๊ฐ
<script src="./node_modules/pixi.js/dist/pixi.min.js"></script>
ํด์ฃผ๊ฑฐ๋ npm์ผ๋ก ๋ค์ด๋ฐ์ง ์๋๋ผ๋ ์๋ ๋ผ์ธ์ ์ถ๊ฐํด์ฃผ๋ฉด ๋๋ค.
<script src="https://pixijs.download/release/pixi.js"></script>
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>PIXI TUTORIAL</title>
</head>
<body>
<script src="./node_modules/pixi.js/dist/pixi.min.js"></script>
<!--npm install pixi.js ๋์ฒด์ฉ <script src="https://pixijs.download/release/pixi.js"></script>-->
<script src="./app.js" defer></script>
<header>
<img src="https://pixijs.download/pixijs-banner-no-version.png"/>
<h1>PIXI STUDY</h1>
</header>
<form>
<select>
<option value="PIXI1">1</option>
<option value="PIXI2">2</option>
<option value="PIXI3">3</option>
<br>
</select>
</form>
<main>
<section>
<ul>
<li>
<p>
<span>
2022๋
12์ 21์ผ
<span>
PIXI ํ๊ฒฝ์ค์ ๊ณผ ๊ธฐ๋ณธ ์์ฑ ํ์ต
<a href = "https://www.youtube.com/watch?v=ajaduDDePIY" target="_blank">(Source1)</a>
<a href = "https://www.youtube.com/watch?v=_HjQTzpbRK4&list=PLGsA9l-S7trVmUJ7HJsNSKIj0qoAO_qO8&index=1" target="_blank">(Source2)</a>
</p>
</li>
</ul>
</section>
</main>
</body>
</html>
์์ ๊ฐ์ด ์์ ์ฝ๋ ์์ฑ
app.js
const Application = PIXI.Application;
const app = new Application();
์ฌ๊ธฐ๊น์ง ํด์ค ๋ค,
์ฝ์์ PIXI๋ฅผ ์์ฑํ๋ฉด,
ํผ์ณ๋ณด๋๋ก ํ๋ค.
์์ฒญ๋๊ฒ ๋ง์ด ๋์จ๋ค...๐
์ด์ ์ค๋ฌด์์ ํฝ์๋
export default class ๊ณ ์์ดํ์
extends ๊ธฐ๋ณธํ์
{
app: PIXI.Application | null;
clickEventHandler!: (e: any) => void;
constructor(parent?: any, options?: any) {
super(parent, options);
this.app = null;
}
destroy() {
this.app!.view.parentElement!.removeEventListener("mousemove", this.clickEventHandler);
super.destroy();
}
}
์์ ๊ฐ์ด ์ฐ์ฌ์ง ์ ์์ ๊ฒ์ด๋ค.
PIXI.Application์ ํด๋์ค์ด๋ค.
class {
constructor(i){
this.stage = new ....
}
renderer... ๋ฑ๋ฑ์ด ๋ด๊ฒจ์ ธ ์๋ ๊ฒ์ด ๋ณด์ธ๋ค.
์ฝ์์์ ์กฐ๊ธ ๋ ๋๋๋ ค๋ณธ๋ค.
stage, renderer, ticker
์ฆ Application์์ PixiJS ์์ ์ ๋จ์ํํ๋ ๋์ฐ๋ฏธ ํด๋์ค๋ก,
๋ ๋๋ฌ๋ฅผ ๋ง๋ค๊ณ , ์คํ ์ด์ง๋ฅผ ๋ง๋ค๊ณ , ์ ๋ฐ์ดํธ๋ฅผ ์ํ ํฐ์ปค๋ฅผ ์์ํ ์ ์์์ ์ ์ ์๋ค.
์ด tempApp.view ๋ฅผ ๋ฐ์ด๋ณด๋ฉด canvas ํ๊ทธ๊ฐ ์ฐํ๋ค.
tempApp์ renderer -> plugins -> interaction ๊น์ง ํ๊ณ ๋ค์ด๊ฐ๋ณด์
ํฌ์ธํฐ๋ค์ด, ํฌ์ธํฐ๋ฌด์ค ๋ฑ์ ์ด๋ฒคํธ ํธ๋ค๋ฌ๊ฐ ๋ณด์ธ๋ค!
์ด pixi app์ dom์ ์ถ๊ฐํด๋ณธ๋ค.
DOM์ ๋ทฐ ์ถ๊ฐ
๋ PIXI. ์์ฉ ํ๋ก๊ทธ๋จ ํด๋์ค๋ ๋ ๋๋ฌ๋ฅผ ๋ง๋ค๊ณ ๋ ๋๋งํ Canvas ์์๋ฅผ ๋น๋. PixiJS๋ก ๊ทธ๋ฆฌ๋ ๊ฒ์ ๋ณด๋ ค๋ฉด ์ด Canvas ์์๋ฅผ ์น ํ์ด์ง์ DOM์ ์ถ๊ฐ. ํ์ด์ง์ ์คํฌ๋ฆฝํธ ๋ธ๋ก์ ๋ค์ ์ค์ ์ถ๊ฐ
document.body.appendChild(app.view);
const Application = PIXI.Application;
const app = new Application();
document.body.appendChild(app.view);
์์ ๊ฐ์ด ํด๋ ๋๊ณ ,
์๋์ ๊ฐ์ด ํด๋ ๋๋ค.
let app = new PIXI.Application({width: 640, height: 360 });
document.body.appendChild(app.view);
์ค๋ฌด์์๋ ํฝ์๋ฅผ ๋ฐ๋ผ ์ฌ๋งํด์๋ app์ด๋ผ๋ ๋ณ์์ ๋ด๋ ๊ฒ์ ๊ถ์ฅํ๋ค.
'Javascript > pixi.js' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[PIXI] ticker ์ฌ์ฉ๋ฐฉ๋ฒ (0) | 2022.12.26 |
---|---|
[PIXI] PIXI.Text์ PIXI.TextStyle ์ฌ์ฉ ๋ฐฉ๋ฒ (0) | 2022.12.26 |
[PIXI] Graphic ํด๋์ค ํ์ฉํ์ฌ ๋ํ๊ทธ๋ฆฌ๊ธฐ (0) | 2022.12.26 |
[PIXI] app.view(์ฌ์ค์ ์บ๋ฒ์ค ํ๊ทธ) ์์ฑ ์ดํด๋ณด๊ธฐ (0) | 2022.12.23 |
[Pixi.js] ํฝ์ ๊ณต๋ถ ์์ (0) | 2022.12.21 |