Add default values and allow passing from the methods

This commit is contained in:
Richard Davey 2023-02-16 18:50:42 +00:00
parent cbf42feee1
commit b7e9fe23af
5 changed files with 68 additions and 41 deletions

View file

@ -210,81 +210,79 @@ var FX = new Class({
this.enable();
}
var instance = new fx(this.gameObject);
this.list.push(fx);
this.list.push(instance);
return instance;
return fx;
},
addGlow: function ()
addGlow: function (distance, outerStrength, innerStrength, knockout, color)
{
return this.add(Effects.Glow);
return this.add(new Effects.Glow(this.gameObject, distance, outerStrength, innerStrength, knockout, color));
},
addShadow: function ()
addShadow: function (x, y, decay, power, color, samples, intensity)
{
return this.add(Effects.Shadow);
return this.add(new Effects.Shadow(this.gameObject, x, y, decay, power, color, samples, intensity));
},
addPixelate: function ()
addPixelate: function (amount)
{
return this.add(Effects.Pixelate);
return this.add(new Effects.Pixelate(this.gameObject, amount));
},
addVignette: function ()
addVignette: function (x, y, radius, strength)
{
return this.add(Effects.Vignette);
return this.add(new Effects.Vignette(this.gameObject, x, y, radius, strength));
},
addShine: function ()
{
return this.add(Effects.Shine);
return this.add(new Effects.Shine(this.gameObject));
},
addBlur: function ()
{
return this.add(Effects.Blur);
return this.add(new Effects.Blur(this.gameObject));
},
addGradient: function ()
{
return this.add(Effects.Gradient);
return this.add(new Effects.Gradient(this.gameObject));
},
addBloom: function ()
{
return this.add(Effects.Bloom);
return this.add(new Effects.Bloom(this.gameObject));
},
addColorMatrix: function ()
{
return this.add(Effects.ColorMatrix);
return this.add(new Effects.ColorMatrix(this.gameObject));
},
addCircle: function ()
{
return this.add(Effects.Circle);
return this.add(new Effects.Circle(this.gameObject));
},
addBarrel: function ()
{
return this.add(Effects.Barrel);
return this.add(new Effects.Barrel(this.gameObject));
},
addDisplacement: function ()
{
return this.add(Effects.Displacement);
return this.add(new Effects.Displacement(this.gameObject));
},
addWipe: function ()
{
return this.add(Effects.Wipe);
return this.add(new Effects.Wipe(this.gameObject));
},
addBokeh: function ()
{
return this.add(Effects.Bokeh);
return this.add(new Effects.Bokeh(this.gameObject));
}
});

View file

@ -25,8 +25,13 @@ var Glow = new Class({
initialize:
function Glow (gameObject)
function Glow (gameObject, distance, outerStrength, innerStrength, knockout, color)
{
if (distance === undefined) { distance = 16; }
if (outerStrength === undefined) { outerStrength = 4; }
if (innerStrength === undefined) { innerStrength = 0; }
if (knockout === undefined) { knockout = false; }
BaseFX.call(this, FX_CONST.GLOW, gameObject);
/**
@ -41,7 +46,7 @@ var Glow = new Class({
* @type {number}
* @since 3.60.0
*/
this.distance = 16;
this.distance = distance;
/**
* The strength of the glow outward from the edge of the Sprite.
@ -50,7 +55,7 @@ var Glow = new Class({
* @type {number}
* @since 3.60.0
*/
this.outerStrength = 4;
this.outerStrength = outerStrength;
/**
* The strength of the glow inward from the edge of the Sprite.
@ -59,7 +64,7 @@ var Glow = new Class({
* @type {number}
* @since 3.60.0
*/
this.innerStrength = 0;
this.innerStrength = innerStrength;
/**
* If `true` on the glow is drawn, not the texture itself.
@ -68,7 +73,7 @@ var Glow = new Class({
* @type {number}
* @since 3.60.0
*/
this.knockout = false;
this.knockout = knockout;
/**
* A 4 element array of gl color values.
@ -78,6 +83,11 @@ var Glow = new Class({
* @since 3.60.0
*/
this.glcolor = [ 1, 1, 1, 1 ];
if (color !== undefined)
{
this.color = color;
}
},
/**

View file

@ -25,11 +25,13 @@ var Pixelate = new Class({
initialize:
function Pixelate (gameObject)
function Pixelate (gameObject, amount)
{
if (amount === undefined) { amount = 1; }
BaseFX.call(this, FX_CONST.PIXELATE, gameObject);
this.amount = 1;
this.amount = amount;
}
});

View file

@ -25,17 +25,29 @@ var Shadow = new Class({
initialize:
function Shadow (gameObject)
function Shadow (gameObject, x, y, decay, power, color, samples, intensity)
{
if (x === undefined) { x = 0; }
if (y === undefined) { y = 0; }
if (decay === undefined) { decay = 0.1; }
if (power === undefined) { power = 1; }
if (samples === undefined) { samples = 6; }
if (intensity === undefined) { intensity = 1; }
BaseFX.call(this, FX_CONST.SHADOW, gameObject);
this.x = 0;
this.y = 0;
this.decay = 0.1;
this.power = 1.0;
this.x = x;
this.y = y;
this.decay = decay;
this.power = power;
this.glcolor = [ 0, 0, 0, 1 ];
this.samples = 6; // max 12, min 1
this.intensity = 1;
this.samples = samples; // max 12, min 1
this.intensity = intensity;
if (color !== undefined)
{
this.color = color;
}
},
/**

View file

@ -25,14 +25,19 @@ var Vignette = new Class({
initialize:
function Vignette (gameObject)
function Vignette (gameObject, x, y, radius, strength)
{
if (x === undefined) { x = 0.5; }
if (y === undefined) { y = 0.5; }
if (radius === undefined) { radius = 0.5; }
if (strength === undefined) { strength = 0.5; }
BaseFX.call(this, FX_CONST.VIGNETTE, gameObject);
this.x = 0.5;
this.y = 0.5;
this.radius = 0.5;
this.strength = 0.5;
this.x = x;
this.y = y;
this.radius = radius;
this.strength = strength;
}
});