Phaser位图乘法不会影响精灵

时间:2016-04-06 03:42:45

标签: javascript phaser-framework

您好我正在尝试使用PhaserJS中的位图乘法制作基本的闪电系统。我怎么会遇到这样一个事实:位图不会使我的精灵变暗。我怎么做到这一点?

我在游戏创建功能中创建了这样的位图。

// Shadow
this.bitmap = this.game.add.bitmapData(
  this.game.width+100,
  this.game.height+100
);
this.lightBitmap = this.game.add.image(0, 0, this.bitmap);
this.lightBitmap.blendMode = Phaser.blendModes.MULTIPLY;

然后我填充它并在更新功能的每一帧中绘制它。

this.bitmap.fill(20, 20, 20, 1);
this.lightBitmap.x = this.camera.x-50;
this.lightBitmap.y = this.camera.y-50;
this.bitmap.dirty = true;

这是一张显示会发生什么的图片。我在半屏幕上画了阴影只是为了说明它不会使精灵变暗。泥瓦和紫色球员是我希望它影响的精灵。

enter image description here

我怎样才能让精灵变暗?

1 个答案:

答案 0 :(得分:1)

这可能是因为您要添加图片的顺序。如果要影响所有元素,则应将阴影添加为最后一个阴影。或者您始终可以使用bringToTop方法。

看一下这个例子:



var game = new Phaser.Game(500, 500, Phaser.AUTO, 'game');
var mainState = { 
 	preload:function(){
      var dataURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAN1wAADdcBQiibeAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAAJdEVYdFRpdGxlAENhcobOmFIAAAALdEVYdEF1dGhvcgBMb3Jpw/Hj0QAAAB90RVh0RGVzY3JpcHRpb24Ac2lkZS12aWV3IG9mIGEgY2FyIB3sOscAAB2qSURBVHic7Zx5mB1Vteh/a++qOnX69Dyk6XRIQiAQBgljLnIJIOhTQHB4gID4QMWrXn1ehw9HvE+v914VfQ6fT5wuguJ4H6iIEzKIDBoZboAECCQk6czpeTp9hqq99/uj6nSf7nQnYQr9va/X962v6uxTw671q73X2mvvc8Q5x5zMHlEvdwXmZLLMAZll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GaZzAGZZTIHZJbJHJBZJnNAZpnMAZllMgdklskckFkmc0BmmcwBmWUyB2SWyRyQWSZzQGaZzAGZZfL/ABQPgU4Ww7kIAAAAAElFTkSuQmCC'
      var data = new Image();
      data.src = dataURI;
      game.cache.addImage('car', dataURI, data);

      var dataURI2 = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAoHSURBVGhD7VgHVFRXGlajLEHjKhEVXOkMMCBlaAIajaxRbHSBUcGGLaKCGGSxYEERhMEuiN1o7BU1gIgFCyKi2PsqdhETTbKrsl/+/82MDDjuWuLZ3XPmO+c797475X3fvf//3/teHQ000EADDTTQQIN3hiFRRNQjNiLWI/5fQJ/Yy8bw89TwrgZHB/oaPZsZ5/hSNsW5YmKU3d+jh4nLhoSJjoT6m+zs3MFgdVtJs3Qby8aTDVpoj6DfSYldiW5ENt+K+GdifeInRwtiN2tDnRmBXzUviAsxfrLyOxscmeuKR9le2CJzw5VDPsCj/sDdMPzrXjhelofh15t9UXlFivtng3HjZCDOHvRFYXY37P2hMzZkdcTSdM+XmakeT+fMcCuPHG5zycqiyfGG2vVymjb8bJz8th8PXaKXmb52go+HXl5MkFHFshgbHJK54OIyD1xd6YnzS91RmuGOaxs6IHOiPQq3dsHTCyF4WNYbj84yg/H4XDCe0FjlpVD8RIaeXe+Dl3fCgKeDgOcReHarH47l9MTSVA8kjrGFbKQVDqQ6Y1p/M9D93QUl74k/ETvq1Kszwd+92Y8TpcYP1sXZ4sQCN9xc0w6317bHlRWeOJPpjuKFbjTuKpD719Z3wMLxbVCw3gtPyoLw4FRgTZYGofJ8MP55ow9+uSbFhUI/bMz6GonjHBAbboGZA82xPs4GxXPlk3Quyx0XqP2rRPcEaXq/XHN1/HLP0P6WiOhtioQIS6RFWiN5iAhzR4iwKNISq2PE2DXFDvuTJThB4VSW4YYLtC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MHh0uD8yWYBNVsfHBRlXeLrr5DbXqRpCclnJVH4Be7nrF/JKBH2SuEC8u9xCO0rzBcWWqFq7Kmia4ZSMFqc6CEd5DWLRqXuylR10Wz61smAWkXze/Zq6vnUISJHIlHwn9pg1G+3g23zvI2+BSvNTk+fxIK2yb4oDD6fQcToYur5C/ArpEBvmxlQ+ANR+Y5OQNlV/n8BGFQ4ZNcALn06Fxf4oEq78T0+n2L8/b2TbZSLf1I34uCPgE0CK2JrZvpFV3gNhIJ6mrs+6W/t/ol8YGGz9OpcfODbQnFFD4sBk2dpUegC6vkL/nYtOHyDwb4cTl2eeVmEpHEz9PvaIWTRvwizczvtF/E82JzsQQs1bakzvaNVkj7aR/PCrA6M7MQeZVq2JthUTnVeQHqyVjLDGwi/49WxOdDPpNB/6D/3U0IYqJPoZ62uPcrL9YYdxCa4tW/brhNMZvLDXQQAMNNNBAAw3Uok6d3wEMwmSh7B0m8QAAAABJRU5ErkJggg==';
      var data2 = new Image();
      data2.src = dataURI2;
      game.cache.addImage('wood', dataURI2, data2);
},

create:function(){
	game.stage.backgroundColor = "#4488AA";
	this.bitmap = game.add.bitmapData(
      200,
      200
    );
  	this.lightBitmap = game.add.image(0, 0, this.bitmap);
	this.lightBitmap.blendMode = Phaser.blendModes.MULTIPLY;

    game.physics.startSystem(Phaser.Physics.ARCADE);
    this.car =this.game.add.sprite(game.world.centerX,game.world.centerY,'car');
    this.car.anchor.setTo(0.5,0.5);

    game.physics.arcade.enable(this.car);
      
  
    game.physics.arcade.enable(this.car);                     
   
    platforms = game.add.group();
    platforms.enableBody = true;

    var ground = platforms.create(100,100, 'wood');
  	var ground2 = platforms.create(400,400, 'wood');
    ground.body.immovable = true;
  	ground2.body.immovable = true;
  
    
},

update:function(){
    this.car.body.velocity.x =0;
    this.car.body.velocity.y = 0;
    if(game.input.keyboard.isDown(Phaser.Keyboard.LEFT)){
        this.car.body.velocity.x = -100;
    }
    if(game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)){
        this.car.body.velocity.x = 100;
    }
    if(game.input.keyboard.isDown(Phaser.Keyboard.UP)){
       this.car.body.velocity.y = -100;
    }
    if(game.input.keyboard.isDown(Phaser.Keyboard.DOWN)){
       
       this.car.body.velocity.y = 100;
    }
       
    
    this.bitmap.fill(50, 50, 50, 1);
    this.lightBitmap.x = this.car.body.x-50;
    this.lightBitmap.y = this.car.body.y-50;
    this.bitmap.dirty = true;
    game.world.bringToTop(this.lightBitmap);
},
};
game.state.add('main', mainState);  
game.state.start('main');

<script src="https://cdnjs.cloudflare.com/ajax/libs/phaser/2.4.4/phaser.min.js"></script>
<div id="game"></div>
&#13;
&#13;
&#13;