【问题标题】:Sprites and equipping sprite clothes in PhaserPhaser 中的精灵和装备精灵衣服
【发布时间】:2016-01-11 03:28:04
【问题描述】:

如何在 Phaser 中为精灵装备衣服?假设我使用以下内容:

我能想到的唯一方法是制作每个精灵的图像。一定有不同的方式,比如叠加之类的?

【问题讨论】:

  • 错误的论坛,mod 会纠正的。但是,是的,您会在角色上叠加“风格”。只要覆盖层是透明的,就可以了。要进行优化,您可以“缓存”应用了叠加层的字符。但同样,错误的论坛,不知道 Phaser 是什么。

标签: javascript phaser-framework


【解决方案1】:

你应该检查这个项目:https://github.com/makrohn/Universal-LPC-spritesheet

对于 Phaser 中的集成,请尝试类似的方法:

function preload() {
    game.load.spritesheet('female_body', 'sprites/body/female/light.png', 64, 64);
    game.load.spritesheet('female_hair', 'sprites/hair/female/pixie/blonde.png', 64, 64);
    game.load.spritesheet('female_torso', 'sprites/torso/tunics/female/teal_tunic.png', 64, 64);
    game.load.spritesheet('female_legs', 'sprites/legs/pants/female/teal_pants_female.png', 64, 64);
};

function create() {
    var group = game.add.group();
    group.add(game.add.sprite(200, 200, 'female_body', 13 * 9));
    group.add(game.add.sprite(200, 200, 'female_hair', 13 * 9));
    group.add(game.add.sprite(200, 200, 'female_torso', 13 * 9));
    group.add(game.add.sprite(200, 200, 'female_legs', 13 * 9));
    group.callAll('animations.add', 'animations', 'walk', Phaser.ArrayUtils.numberArrayStep(13 * 9, 13 * 9 + 9));
    group.callAll('animations.play', 'animations', 'walk', 9, true);
};

【讨论】:

    【解决方案2】:

    您可以使用Phaser.Sprite#addChild 将布料精灵附加到您的玩家精灵。

    // Player sprite
    var player = game.add.sprite(0, 0, 'player-sprite');
    
    // Cloth sprite
    var cloth = game.add.sprite(0, 0, 'cloth-sprite');
    
    // Tweak anchor position to correctly align clothing over player 
    cloth.anchor.setTo(0.5, 0.5);
    
    player.addChild(cloth);
    

    【讨论】:

      猜你喜欢
      • 2017-05-27
      • 2018-03-21
      • 2014-08-26
      • 2018-05-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多