How I created dynamic lower thirds with chroma key using Phaser
Talking about HTML5, Javascript and Phaser.
Do you like my tutorials?
Then consider supporting me on Ko-fi.
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.