mirror of
https://github.com/photonstorm/phaser
synced 2024-11-10 23:24:41 +00:00
Opps forgot to fix a rogue filter which caused the lib to crash.
This commit is contained in:
parent
496639ff25
commit
b286093093
6 changed files with 521 additions and 393 deletions
|
@ -68,6 +68,7 @@ module.exports = function (grunt) {
|
|||
'src/core/LinkedList.js',
|
||||
'src/core/Signal.js',
|
||||
'src/core/SignalBinding.js',
|
||||
'src/core/Filter.js',
|
||||
'src/core/Plugin.js',
|
||||
'src/core/PluginManager.js',
|
||||
'src/core/Stage.js',
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<script src="../src/pixi/filters/DisplacementFilter.js"></script>
|
||||
<script src="../src/pixi/filters/DotScreenFilter.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/GreyFilter.js"></script>
|
||||
<script src="../src/pixi/filters/GrayFilter.js"></script>
|
||||
<script src="../src/pixi/filters/InvertFilter.js"></script>
|
||||
<script src="../src/pixi/filters/PixelateFilter.js"></script>
|
||||
<script src="../src/pixi/filters/RGBSplitFilter.js"></script>
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<script src="../src/pixi/filters/DisplacementFilter.js"></script>
|
||||
<script src="../src/pixi/filters/DotScreenFilter.js"></script>
|
||||
<script src="../src/pixi/filters/FilterBlock.js"></script>
|
||||
<script src="../src/pixi/filters/GreyFilter.js"></script>
|
||||
<script src="../src/pixi/filters/GrayFilter.js"></script>
|
||||
<script src="../src/pixi/filters/InvertFilter.js"></script>
|
||||
<script src="../src/pixi/filters/PixelateFilter.js"></script>
|
||||
<script src="../src/pixi/filters/RGBSplitFilter.js"></script>
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
}
|
||||
</style>
|
||||
<script src="phaser.js"></script>
|
||||
<script src="../../../filters/ColorBars.js" type="text/javascript"></script>
|
||||
<script src="../../../filters/BinarySerpents.js" type="text/javascript"></script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
@ -17,117 +19,9 @@
|
|||
|
||||
<script type="text/javascript">
|
||||
|
||||
var PIXI = PIXI || {};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
function makeFilter () {
|
||||
|
||||
PIXI.FireFilter = function(width, height, texture)
|
||||
{
|
||||
PIXI.AbstractFilter.call( this );
|
||||
|
||||
this.passes = [this];
|
||||
|
||||
var d = new Date();
|
||||
|
||||
var dates = [
|
||||
d.getFullYear(), // the year (four digits)
|
||||
d.getMonth(), // the month (from 0-11)
|
||||
d.getDate(), // the day of the month (from 1-31)
|
||||
d.getHours()*60.0*60 + d.getMinutes()*60 + d.getSeconds()
|
||||
];
|
||||
|
||||
this.uniforms = {
|
||||
resolution: { type: 'f2', value: { x: width, y: height }},
|
||||
mouse: { type: 'f2', value: { x: 0, y: 0 }},
|
||||
time: { type: 'f', value: 1 }
|
||||
};
|
||||
|
||||
// http://glsl.heroku.com/e#11707.0
|
||||
|
||||
// Heroku shader conversion
|
||||
this.fragmentSrc = [
|
||||
|
||||
"#ifdef GL_ES",
|
||||
"precision mediump float;",
|
||||
"#endif",
|
||||
|
||||
"uniform float time;",
|
||||
"uniform vec2 mouse;",
|
||||
"uniform vec2 resolution;",
|
||||
|
||||
"vec3 iResolution = vec3(resolution.x,resolution.y,100.);",
|
||||
"vec4 iMouse = vec4(mouse.x,mouse.y,5.,5.);",
|
||||
"float iGlobalTime = time;",
|
||||
"uniform sampler2D iChannel0;",
|
||||
|
||||
"// by @301z",
|
||||
|
||||
"float rand(vec2 n) {",
|
||||
"return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);",
|
||||
"}",
|
||||
|
||||
"// Genera ruido en función de las coordenadas del pixel",
|
||||
"float noise(vec2 n) {",
|
||||
"const vec2 d = vec2(0.0, 1.0);",
|
||||
"vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));",
|
||||
"return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);",
|
||||
"}",
|
||||
|
||||
"// Fractional Brownian Amplitude. Suma varias capas de ruido.",
|
||||
"float fbm(vec2 n) {",
|
||||
"float total = 0.0, amplitude = 1.0;",
|
||||
"for (int i = 0; i < 4; i++) {",
|
||||
"total += noise(n) * amplitude;",
|
||||
"n += n;",
|
||||
"amplitude *= 0.5;",
|
||||
"}",
|
||||
"return total;",
|
||||
"}",
|
||||
|
||||
"void main() {",
|
||||
"// Colores",
|
||||
"const vec3 c1 = vec3(0.5, 0.0, 0.1); // Rojo oscuro.",
|
||||
"const vec3 c2 = vec3(0.9, 0.0, 0.0); // Rojo claro.",
|
||||
"const vec3 c3 = vec3(0.2, 0.0, 0.0); // Rojo oscuro.",
|
||||
"const vec3 c4 = vec3(1.0, 0.9, 0.0); // Amarillo.",
|
||||
"const vec3 c5 = vec3(0.1); // Gris oscuro.",
|
||||
"const vec3 c6 = vec3(0.9); // Gris claro.",
|
||||
|
||||
"vec2 p = gl_FragCoord.xy * 8.0 / iResolution.xx; // Desfasa las coordenadas para que haya más cambio de un resultado a los colindantes.",
|
||||
"float q = fbm(p - iGlobalTime * 0.1); // Ruido con offset para el movimiento.",
|
||||
"vec2 r = vec2(fbm(p + q + iGlobalTime * 0.7 - p.x - p.y), fbm(p + q - iGlobalTime * 0.4));",
|
||||
"vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);",
|
||||
"gl_FragColor = vec4(c *",
|
||||
"cos(1.57 * gl_FragCoord.y / iResolution.y), // Gradiente más ocuro arriba.",
|
||||
"1.0);",
|
||||
"}"];
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
PIXI.FireFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
|
||||
PIXI.FireFilter.prototype.constructor = PIXI.FireFilter;
|
||||
|
||||
Object.defineProperty(PIXI.FireFilter.prototype, 'iGlobalTime', {
|
||||
get: function() {
|
||||
return this.uniforms.time.value;
|
||||
},
|
||||
set: function(value) {
|
||||
this.uniforms.time.value = value;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
var game = new Phaser.Game(1024, 672, Phaser.AUTO, 'gameContainer', { preload: preload, create: create, update: update });
|
||||
|
||||
var filter;
|
||||
var filter;
|
||||
|
||||
var sky;
|
||||
var land;
|
||||
|
@ -175,10 +69,6 @@ var filter;
|
|||
|
||||
function create () {
|
||||
|
||||
console.log('dom?');
|
||||
console.log(Phaser);
|
||||
console.log(PIXI);
|
||||
|
||||
game.world.setBounds(-64, 0, 1300, 672);
|
||||
|
||||
sfxLazer = game.add.audio('sfxLazer', 0.1, false);
|
||||
|
@ -187,11 +77,14 @@ console.log(PIXI);
|
|||
music = game.add.audio('music');
|
||||
|
||||
sky = game.add.sprite(0, 0, 'background');
|
||||
makeFilter();
|
||||
filter = new PIXI.FireFilter(sky.width, sky.height, sky.texture);
|
||||
sky.filters = [filter];
|
||||
|
||||
// sky = game.add.sprite(0, 0, 'background');
|
||||
var t = game.add.sprite(0, 0);
|
||||
t.width = 1024;
|
||||
t.height = 672;
|
||||
filter = game.add.filter('BinarySerpents', 1024, 672);
|
||||
// filter.alpha = 0.0;
|
||||
t.filters = [filter];
|
||||
|
||||
land = game.add.tileSprite(0, 544, 1024, 128, 'land');
|
||||
|
||||
bullets = game.add.group();
|
||||
|
@ -285,7 +178,7 @@ console.log(PIXI);
|
|||
|
||||
function update () {
|
||||
|
||||
filter.iGlobalTime = game.time.totalElapsedSeconds();
|
||||
filter.update();
|
||||
|
||||
land.tilePosition.x -= scrollSpeed;
|
||||
|
||||
|
@ -430,8 +323,6 @@ console.log(PIXI);
|
|||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -92,11 +92,13 @@ Phaser.World.prototype.update = function () {
|
|||
skipChildren = (currentNode.update() === false) || skipChildren;
|
||||
}
|
||||
|
||||
if(skipChildren)
|
||||
if (skipChildren)
|
||||
{
|
||||
currentNode = currentNode.last._iNext;
|
||||
} else {
|
||||
currentNode = currentNode._iNext;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentNode = currentNode._iNext;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue