Trying out flash effect.

This commit is contained in:
photonstorm 2016-10-19 17:17:26 +01:00
parent d19148aec0
commit 64cd88f7b4
4 changed files with 42 additions and 5 deletions

View file

@ -4,6 +4,8 @@
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
// "First do it, then do it right, then do it better" - Addy Osmani
/**
* @namespace Phaser
*/
@ -14,7 +16,7 @@ var Phaser = Phaser || { // jshint ignore:line
* @constant
* @type {string}
*/
VERSION: '3.0.0.r4',
VERSION: '3.0.0.r5',
/**
* An array of Phaser game instances.

View file

@ -522,8 +522,8 @@ Phaser.StateManager.prototype = {
* @param {string} key - State key.
* @private
*/
setCurrentState: function (key) {
setCurrentState: function (key)
{
this.callbackContext = this.states[key];
this.link(key);

View file

@ -69,10 +69,44 @@ Phaser.Renderer.Canvas.GameObjects.Image = {
var cw = frame.cutWidth;
var ch = frame.cutHeight;
var cwr = cw / resolution;
var chr = ch / resolution;
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, tx, ty);
// Color Component
if (src.color._hasBackground)
{
// context save?
renderer.context.fillStyle = src.color._rgba;
renderer.context.fillRect(dx, dy, cwr, chr);
}
// renderer.context.drawImage(source.image, frame.cutX, frame.cutY, cw, ch, dx, dy, cw / resolution, ch / resolution);
// Test drawing over the top
// renderer.currentBlendMode = src.blendMode;
// TESTS Works fine :)
if (src.texture.key === 'bunny')
{
renderer.context.drawImage(source.image, frame.cutX, frame.cutY, cw, ch, dx, dy, cw / resolution, ch / resolution);
renderer.context.save();
// renderer.context.globalCompositeOperation = 'source-in';
renderer.context.globalCompositeOperation = 'xor';
renderer.context.beginPath();
renderer.context.fillStyle = 'rgba(255,0,255,0.5)';
renderer.context.fillRect(dx, dy, cwr, chr);
renderer.context.closePath();
// renderer.context.drawImage(source.image, frame.cutX, frame.cutY, cw, ch, dx, dy, cw / resolution, ch / resolution);
renderer.context.restore();
renderer.context.globalCompositeOperation = 'source-over';
}
else
{
renderer.context.drawImage(source.image, frame.cutX, frame.cutY, cw, ch, dx, dy, cw / resolution, ch / resolution);
}
/*
// Move this to either the Renderer, or the Texture Manager, but not here (as it's repeated all over the place)

View file

@ -131,7 +131,8 @@ Phaser.Renderer.WebGL.BatchManager = function (renderer)
'void main(void) {',
' vec4 pixel = texture2D(uSampler, vTextureCoord) * vTintColor;', // get the color from the texture
' if (pixel.a == 0.0) pixel = vBgColor;', // if texture alpha is zero, use the bg color
// ' if (pixel.a == 0.0) pixel = vBgColor;', // if texture alpha is zero, use the bg color
' if (pixel.a > 0.0) pixel = PINK;', // if texture alpha is zero, use the bg color
' gl_FragColor = pixel;',
'}'
];