From f9cad58082296add2429aa7a6d7276a98d6f20a1 Mon Sep 17 00:00:00 2001 From: photonstorm Date: Tue, 4 Mar 2014 01:40:02 +0000 Subject: [PATCH] Labs code updates. --- labs/code/006 bitmap fonts ahoy.js | 2 +- labs/code/010 fixed to camera.js | 2 +- labs/code/011 font wobble.js | 112 +++++++++++++++++++++++++++++ labs/view_remote.php | 4 +- 4 files changed, 115 insertions(+), 5 deletions(-) create mode 100644 labs/code/011 font wobble.js diff --git a/labs/code/006 bitmap fonts ahoy.js b/labs/code/006 bitmap fonts ahoy.js index 6af0d0bb..201bbf1d 100644 --- a/labs/code/006 bitmap fonts ahoy.js +++ b/labs/code/006 bitmap fonts ahoy.js @@ -3,7 +3,7 @@ var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: p function preload() { - game.load.image('knightHawks', 'assets/fonts/KNIGHT3.png'); + game.load.image('knightHawks', 'assets/fonts/retroFonts/KNIGHT3.png'); } diff --git a/labs/code/010 fixed to camera.js b/labs/code/010 fixed to camera.js index d900f3ef..0f0faf38 100644 --- a/labs/code/010 fixed to camera.js +++ b/labs/code/010 fixed to camera.js @@ -6,7 +6,7 @@ function preload() { game.load.image('backdrop', 'assets/pics/remember-me.jpg'); game.load.image('mushroom', 'assets/sprites/mushroom2.png'); game.load.image('coke', 'assets/sprites/cokecan.png'); - game.load.bitmapFont('desyrel', 'assets/fonts/desyrel.png', 'assets/fonts/desyrel.xml', null, 0, -32); + game.load.bitmapFont('desyrel', 'assets/fonts/bitmapFonts/desyrel.png', 'assets/fonts/bitmapFonts/desyrel.xml', null, 0, -32); } diff --git a/labs/code/011 font wobble.js b/labs/code/011 font wobble.js new file mode 100644 index 00000000..d96a2d9b --- /dev/null +++ b/labs/code/011 font wobble.js @@ -0,0 +1,112 @@ + +var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create, update: update }); + +function preload() { + + game.load.image('knightHawks', 'assets/fonts/retroFonts/KNIGHT3.png'); + +} + +var font; +var images; +var dataV; +var dataH; +var dataH2; +var sine = 0; +var total = 24; +var posV = []; +var posH = []; +var text = [ 'phaser v2', 'this march', 'yay retro fonts!', 'shaders', 'filters', 'blend modes', 'full body physics', 'and cats', '(maybe not cats)', '------------' ]; +var textIndex = 0; + +function create() { + + game.stage.smoothed = true; + + font = game.add.retroFont('knightHawks', 31, 25, Phaser.RetroFont.TEXT_SET6, 10, 1, 1); + font.text = 'phaser v2'; + + // Let's create 2 sets of generated tween data - one going vertically, one going horizontally, at different speeds + var tweenData = { x: 200, y: 64 }; + + tween = game.make.tween(tweenData).to( { y: 500 }, 2000, Phaser.Easing.Sinusoidal.InOut); + tween.yoyo(true); + tween.interpolation(game.math.catmullRomInterpolation); + dataV = tween.generateData(60); + + tween = game.make.tween(tweenData).to( { x: 600 }, 1500, Phaser.Easing.Sinusoidal.InOut); + tween.yoyo(true); + tween.interpolation(game.math.catmullRomInterpolation); + dataH = tween.generateData(60); + + tween = game.make.tween(tweenData).to( { x: 600 }, 1500, Phaser.Easing.Elastic.InOut); + tween.yoyo(true); + tween.interpolation(game.math.catmullRomInterpolation); + dataH2 = tween.generateData(60); + + images = game.add.group(); + + var tmp; + + for (var i = 0; i < total; i++) + { + tmp = images.create(game.world.centerX, 64, font); + tmp.anchor.set(0.5); + tmp.scale.set(2); + // tmp.alpha = (1.0 / total) * i; + posV.push(i * 4); + posH.push(i); + } + + images.reverse(); + + game.time.events.loop(4000, updateText, this); + game.time.events.loop(6000, updateSine, this); + +} + +function updateSine() { + + sine++; + + if (sine === 2) + { + sine = 0; + } + +} + +function updateText() { + + textIndex = game.math.wrapValue(textIndex, 1, text.length); + + font.text = text[textIndex]; + +} + +function update() { + + var pv, ph; + + for (var i = 0; i < total; i++) + { + pv = posV[i]; + ph = posH[i]; + + if (sine === 0) + { + images.getAt(i).x = dataH[ph].x; + } + else + { + images.getAt(i).x = dataH2[ph].x; + } + + images.getAt(i).y = dataV[pv].y; + + posV[i] = game.math.wrapValue(pv, 1, dataV.length); + posH[i] = game.math.wrapValue(ph, 1, dataH.length); + + } + +} diff --git a/labs/view_remote.php b/labs/view_remote.php index edbadd17..6ecc82a7 100644 --- a/labs/view_remote.php +++ b/labs/view_remote.php @@ -19,9 +19,7 @@ - +