2016-02-26 56 views
0

我用TexturePacker創建一個JSON文件spritesheet,這是我的代碼位:移相spritesheet裝載旋轉90cw

var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { 
    preload: preload, 
    create: create, 
    update: update 
}); 

function preload() { 
    game.load.atlas('seyan_f_torch', '../sprite_hashes/seyan_f_torch.png', '../sprite_hashes/seyan_f_torch.json'); 
}; 

function create() { 
    var seyan_f_torch = game.add.sprite(20, 20, 'seyan_f_torch', '00219001.png'); 
    console.log(Phaser.Animation.generateFrameNames('00', 219016, 219023, '')); 
    seyan_f_torch.animations.add('walk-s', Phaser.Animation.generateFrameNames('00', 219016, 219023, '.png'), 10, true); 
    // seyan_f_torch.animations.play('walk-s'); 
}; 

function update() { 

}; 

一切正常,這是JSON代碼位:

"00219001.png": 
{ 
    "frame": {"x":782,"y":139,"w":37,"h":58}, 
    "rotated": true, 
    "trimmed": true, 
    "spriteSourceSize": {"x":39,"y":67,"w":37,"h":58}, 
    "sourceSize": {"w":120,"h":240}, 
    "pivot": {"x":0.5,"y":0.5} 
}, 

但是,當加載圖像加載這樣的:

enter image description here

關於如何讓它轉向正確的方式的任何信息將非常感謝。

編輯:

看來移相器不具有旋轉地圖集支持,所以,如果你在我的情況下使用紋理包,取消旋轉圖像。 https://github.com/photonstorm/phaser/issues/2359#issuecomment-189161540

回答

0

Phaser forum:因爲它是一個可能的解決方案,但是從Photonstorm聽到的反饋後,他們似乎不支持旋轉Atlas地圖

// Set anchor to the center of your sprite 
sprite.anchor.setTo(.5, .5); 

// Invert scale.x to flip left/right 
sprite.scale.x *= -1; 

// Invert scale.y to flip up/down 
sprite.scale.y *= -1; 
+0

謝謝,我會記住這作爲一個答案。 – Datsik