2017-02-18 2 views
0

이 버그를 표시하기 위해 codepen을 생성했습니다.페이저 직사각형 스트 레지 동작

업데이트 기능 :

update: function(){ 
    this.timeBar.width = this.timeBar.width - 1; 

은 폭을 변경하도록 설정된다. 그러나 크롬에서 보아도 위치가 바뀌는 것처럼 보입니다. 이것은 버그입니까, 아니면이 코드를 작성하는 동안 고려하지 않은 것입니까?

+0

에 오신 것을 환영합니다! 귀하의 질문에 대한 전체 내용은 링크 된 것이 아니라 귀하의 질문 **에 ** 있어야합니다. 링크 썩어, 미래의 사람들에게 질문과 그 답변을 쓸모없는 만들고, 사람들이 당신을 돕기 위해 오프 사이트로 이동해서는 안됩니다. 질문에 [mcve] **를 넣으십시오. Stack Snippets ('<>'도구 모음 단추)를 사용하여 실행 가능하게 만드는 것이 이상적입니다. 기타 : [* 좋은 질문이 있습니까?] (/ help/how-to-ask) –

+0

Thx 제거, 링크 형식. –

답변

0

그것은 다소 그래픽을 사용하여 복잡하지만 난의 BitmapData를 사용하여 예를 찾을 수 있습니다 스택 오버플로

create: function(){ 
    var bmd = this.game.add.bitmapData(300, 40); 
     bmd.ctx.beginPath(); 
     bmd.ctx.rect(0, 0, 300, 80); 
     bmd.ctx.fillStyle = '#00685e'; 
     bmd.ctx.fill(); 

    var bglife = this.game.add.sprite(this.game.world.centerX, this.game.world.centerY, bmd); 
    bglife.anchor.set(0.5); 

    bmd = this.game.add.bitmapData(280, 30); 
    bmd.ctx.beginPath(); 
     bmd.ctx.rect(0, 0, 300, 80); 
     bmd.ctx.fillStyle = '#FFFFFF'; 
     bmd.ctx.fill(); 

    this.widthLife = new Phaser.Rectangle(0, 0, bmd.width, bmd.height); 
    this.totalLife = bmd.width; 

    this.life = this.game.add.sprite(this.game.world.centerX - bglife.width/2 + 10, this.game.world.centerY, bmd); 
    this.life.anchor.y = 0.5; 
    this.life.cropEnabled = true; 
    this.life.crop(this.widthLife); 

    this.scheduler = this.game.time.events.loop(1500, this.cropLife, this); 
    }, 

    cropLife: function(){ 
    if(this.widthLife.width <= 0){ 
     this.widthLife.width = this.totalLife; 
     this.scheduler.stop(); 
    } 
    else{ 
     this.game.add.tween(this.widthLife).to({ width: (this.widthLife.width - (this.totalLife/10)) }, 200, Phaser.Easing.Linear.None, true); 
    } 
    }, 

    update: function(){ 
    this.life.updateCrop(); 
    } 

You can see the discussion in detail here

+0

그래픽을 삭제하고 다시 그려서 다른 방법으로 문제를 해결했지만 도움을 주셔서 감사합니다. – GuruYaya