mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
filter test updates
This commit is contained in:
@@ -17,6 +17,8 @@ Try out 150+ [Phaser Examples](http://gametest.mobi/phaser/examples/)
|
||||
|
||||
[Un-official Getting Started with Phaser](http://www.antonoffplus.com/coding-an-html5-game-for-30-minutes-or-an-introduction-to-the-phaser-framework)
|
||||
|
||||
[Subscribe to our new Phaser Newsletter](https://confirmsubscription.com/h/r/369DE48E3E86AF1E). We'll email you when new versions are released as well as send you our regular Phaser game making magazine.
|
||||
|
||||
"Being negative is not how we make progress" - Larry Page, Google
|
||||
|
||||
Welcome to Phaser
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 5.4 KiB |
@@ -0,0 +1,68 @@
|
||||
PIXI.GreyFilter = function()
|
||||
{
|
||||
PIXI.AbstractFilter.call( this );
|
||||
|
||||
this.passes = [this];
|
||||
|
||||
// set the uniforms
|
||||
this.uniforms = {
|
||||
grey: {type: 'f', value: 1},
|
||||
};
|
||||
|
||||
this.OLDfragmentSrc = [
|
||||
"precision mediump float;",
|
||||
"varying vec2 vTextureCoord;",
|
||||
"varying float vColor;",
|
||||
"uniform sampler2D uSampler;",
|
||||
"uniform float grey;",
|
||||
"void main(void) {",
|
||||
"gl_FragColor = texture2D(uSampler, vTextureCoord);",
|
||||
"gl_FragColor.rgb = mix(gl_FragColor.rgb, vec3(0.2126*gl_FragColor.r + 0.7152*gl_FragColor.g + 0.0722*gl_FragColor.b), grey);",
|
||||
"gl_FragColor = gl_FragColor * vColor;",
|
||||
"}"
|
||||
];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
PIXI.GreyFilter.prototype = Object.create( PIXI.AbstractFilter.prototype );
|
||||
PIXI.GreyFilter.prototype.constructor = PIXI.GreyFilter;
|
||||
|
||||
/**
|
||||
The strength of the grey. 1 will make the object black and white, 0 will make the object its normal color
|
||||
@property grey
|
||||
*/
|
||||
Object.defineProperty(PIXI.GreyFilter.prototype, 'grey', {
|
||||
get: function() {
|
||||
return this.uniforms.grey.value;
|
||||
},
|
||||
set: function(value) {
|
||||
this.uniforms.grey.value = value;
|
||||
}
|
||||
});
|
||||
|
||||
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('atari1', 'assets/sprites/atari130xe.png');
|
||||
game.load.image('coke', 'assets/sprites/cokecan.png');
|
||||
game.load.image('mushroom', 'assets/sprites/mushroom2.png');
|
||||
|
||||
}
|
||||
|
||||
function create() {
|
||||
|
||||
game.add.sprite(60, 100, 'atari1');
|
||||
game.add.sprite(360, 200, 'coke');
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
$output = "this.fragmentSrc = [\n";
|
||||
|
||||
if (isset($_POST['shader']))
|
||||
{
|
||||
$shader = explode("\n", $_POST['shader']);
|
||||
|
||||
for ($i = 0; $i < count($shader); $i++)
|
||||
{
|
||||
$output = $output . "\t\"" . trim($shader[$i]) . "\",\n";
|
||||
}
|
||||
}
|
||||
|
||||
$output .= "];";
|
||||
?>
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>phaser - filter conv</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form action="filterconv.php" method="post">
|
||||
|
||||
<h2>Input</h2>
|
||||
<textarea name="shader" style="width: 800px; height: 400px"></textarea>
|
||||
|
||||
<h2>Output</h2>
|
||||
<textarea style="width: 800px; height: 400px"><?php echo $output ?></textarea>
|
||||
|
||||
<br />
|
||||
|
||||
<input type="submit" value="Convert" />
|
||||
|
||||
</form>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
Binary file not shown.
@@ -270,7 +270,11 @@ Phaser.Animation.prototype = {
|
||||
else
|
||||
{
|
||||
this.currentFrame = this._frameData.getFrame(this._frames[this._frameIndex]);
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
|
||||
if (this.currentFrame)
|
||||
{
|
||||
this._parent.setTexture(PIXI.TextureCache[this.currentFrame.uuid]);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -474,7 +474,6 @@ PIXI.DisplayObject.prototype.removeFilter = function(data)
|
||||
{
|
||||
//if(!this.filter)return;
|
||||
//this.filter = false;
|
||||
console.log("YUOIO")
|
||||
// modify the list..
|
||||
var startBlock = data.start;
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ PIXI.WebGLRenderGroup = function(gl, transparent)
|
||||
|
||||
this.batchs = [];
|
||||
this.toRemove = [];
|
||||
console.log(this.transparent)
|
||||
this.filterManager = new PIXI.WebGLFilterManager(this.transparent);
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ PIXI._CompileShader = function(gl, shaderSrc, shaderType)
|
||||
gl.compileShader(shader);
|
||||
|
||||
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
|
||||
console.log(gl.getShaderInfoLog(shader));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user