2017-05-16 16 views
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에 대해 매우 새롭다. 이것을 어떻게 처리해야할지 모르겠다.

답변

1

는 다시 :) 이 https://pixijs.github.io/examples/ 그들은 자동으로 다시 시세와 같은 일반적인 일을 설정하는 PIXI.Application 클래스를 사용

이 단계 렌더링 공식 픽시의 예를 살펴 보자 무대를 렌더링 할 필요가

+0

감사합니다. 나는 처음으로 pixi 응용 프로그램을하고 있었다. 무대를 다시 렌더링하면 효과가있었습니다. :) –