0
샘플 pixi 응용 프로그램을 만들려고했습니다. 이미지가있는 곳에서 사용자가 이미지를 클릭하면 위치가 이동해야합니다.스프라이트를 클릭 할 때 Pixi가 위치를 변경하지 않습니다.
var canvasWidth = window.innerWidth;
var canvasHight = window.innerHeight
var renderer = PIXI.autoDetectRenderer(canvasWidth, canvasHight);
document.body.appendChild(renderer.view);
var stage = new PIXI.Container();
PIXI.loader
.add('images/sample.png')
.add('images/background.jpg')
.load(setup);
function setup() {
var backGround = new PIXI.Sprite(
PIXI.loader.resources["images/background.jpg"].texture);
var steve = new PIXI.Sprite(
PIXI.loader.resources["images/sample.png"].texture);
backGround.hieght = canvasHight;
backGround.width = canvasWidth;
setPropertiesToSteve(steve);
stage.addChild(backGround);
stage.addChild(steve);
renderer.render(stage);
}
// Function just to set properties for steve
function setPropertiesToSteve(steve) {
steve.interactive = true;
steve.position.x = canvasWidth/2;
steve.position.x = canvasWidth/4;
steve.on('pointerdown',function(){
steve.position.x = steve.position.x + 10;
});
}
하지만 개체를 클릭하면 아무 일도 일어나지 않습니다. 나는 pixijs에 대해 매우 새롭다. 이것을 어떻게 처리해야할지 모르겠다.
감사합니다. 나는 처음으로 pixi 응용 프로그램을하고 있었다. 무대를 다시 렌더링하면 효과가있었습니다. :) –