Talking about HTML5, Javascript and Phaser.
Who said Phaser can only be used to make games? I am going to tell you tell story of a video project, and how Phaser helped me to work with streaming video. As a company, we are making a continue event streaming on YouTube featuring webcams placed around Venice, panoramic videos of the city taken with a drone, time lapse videos with cameras placed for a day or two in beautiful spots, and some more stuff related to tourism and the promotion of Venice. We are using XSplit to broadcast and automatically switch among the various videos with a plugin we developed. But we also needed something to create quality lower thirds with contents dynamically loaded from a database of events and sponsors. From Wikipedia: In the television industry, a lower third is a graphic overlay placed in the title-safe lower area of the screen, though not necessarily the entire lower third of it, as the name suggests. In its simplest form, a lower third can just be text overlying the video. Frequently this text is white with a drop shadow to make the words easier to read. A lower third can also contain graphical elements such as boxes, images or shading. Some lower thirds have animated backgrounds and text. Our lower third will be placed on the video output using the Chroma Key technique. From Wikipedia again: Chroma key compositing, or chroma keying, is a visual effects / post-production technique for compositing (layering) two images or video streams together based on color hues (chroma range). The technique has been used heavily in many fields to remove a background from the subject of a photo or video – particularly the newscasting, motion picture and videogame industries. There are some software products which create lower thirds on the fly, but they are expensive and it’s not easy to connect them with a MySQL database, so here’s the plan: a green Phaser “game” with the lower third animated with tweens and bitmap fonts. While I can’t show you the entire project at the moment – it isn’t even ready – I am showing you the lower thirds we are working on: The green background will then be used as chroma key to releveal underneath video, and everything will work fine. I will show you the complete project once it’s done. Here is the source code:
var game;
window.onload = function() {
game = new Phaser.Game(1920, 1080, Phaser.CANVAS);
game.state.add("Play", play);
game.state.start("Play");
}
var play = function(){}
play.prototype = {
preload: function(){
game.load.image("mainthird", "mainthird.png");
game.load.image("lowerthird", "lowerthird.png");
game.load.bitmapFont("font", "font.png", "font.fnt");
},
create: function(){
game.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;
game.scale.pageAlignHorizontally = true;
game.scale.pageAlignVertically = true;
game.stage.disableVisibilityChange = true;
game.stage.backgroundColor = 0x00ff00;
this.lowerthird = game.add.sprite(650, game.height - 400, "lowerthird");
this.lowerthird.anchor.set(0.5);
this.lowerthird.visible = false;
this.mainthird = game.add.sprite(0, game.height - 400, "mainthird");
this.mainthird.scale.x = 0.1;
this.mainthird.scale.y = 0.1;
this.mainthird.anchor.set(0.5);
var tween = game.add.tween(this.mainthird).to({
x: 850
}, 200, Phaser.Easing.Linear.None, true);
tween.onComplete.add(function(){
var tween = game.add.tween(this.mainthird.scale).to({
x: 1,
y: 1
}, 600, Phaser.Easing.Cubic.InOut, true);
tween.onComplete.add(function(){
var mainText = game.add.bitmapText(140, game.height - 390, "font", "Palazzo Grassi - From Big Moghul to Maharaja", 72);
mainText.anchor.set(0, 0.5);
this.lowerthird.visible = true;
var tween = game.add.tween(this.lowerthird).to({
y: game.height - 320
}, 700, Phaser.Easing.Bounce.Out, true);
tween.onComplete.add(function(){
var upperText = game.add.bitmapText(180, game.height - 285, "font", "TODAY 8 AM - 5 PM", 60);
upperText.anchor.set(0, 0.5);
}, this)
}, this)
}, this)
game.time.events.add(Phaser.Timer.SECOND * 10, function(){
game.state.start("Play");
}, this);
}
}
Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.