Skip to content
Snippets Groups Projects
Commit 84f56b62 authored by M3156's avatar M3156
Browse files

finished the phaser course

parent 17adbc50
No related branches found
No related tags found
No related merge requests found
Pipeline #176572 passed
......@@ -6,6 +6,7 @@
</title>
<script src="phaser/phaser.min.js"></script>
<link rel="stylesheet" href="main.css">
<!-- <link href="https://fonts.googleapis.com/css?family=Dancing+Script:500&display=swap" rel="stylesheet"> -->
<script src="state0.js"></script>
<script src="state1.js"></script>
<script src="state2.js"></script>
......
var text;
WebFontConfig = {
google: { families: [ 'Dancing Script', 'Inconsolata' ] }
};
demo.state8 = function(){};
demo.state8.prototype = {
preload: function(){},
preload: function(){
game.load.script('webfont', '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js');
},
create: function(){
game.stage.backgroundColor = '#000066';
addChangeStateEventListeners();
text = 'I know it seems hard sometimes but remember one thing. Through every dark night, there is a bright day after that. So no matter how hard it get, stick your chest out, keep ya head up.... and handle it.'
this.spellOutText(100, 150, 1000, text, 50, 40, '#fff', 'Dancing Script');
this.spellOutText(100, 550, 1000, text, 50, 20, '#ff0000', 'Inconsolata');
},
update: function(){}
spellOutText: function(x, y, width, text, fontSize, speed, fill, font){
var sentence = game.add.text(x, y, '', {fontSize: fontSize + 'px', fill: fill, font: font});
var currentLine = game.add.text(10, 10, '', {fontSize: fontSize + 'px', font: font});
currentLine.alpha = 0;
var loop = game.time.events.loop(speed, addChar);
var index = 0;
function addChar(){
sentence.text += text[index];
currentLine.text += text[index];
if(currentLine.width > width && text[index] == ' ') {
sentence.text += '\n';
currentLine.text = '';
}
if (index >= text.length -1) {
game.time.events.remove(loop);
console.log('stop');
}
index++;
}
}
}
\ No newline at end of file
......@@ -8,7 +8,7 @@
<h2>Samson Azizyan (M3156)</h2>
<a href="https://gitlab.labranet.jamk.fi/M3156/ttos0700-peliohjelmointi">GIT repo</a><br>
<a href="http://m3156.pages.labranet.jamk.fi/ttos0700-peliohjelmointi/harkka2/phaser-game-1.html">Harkka 2 - Ensimmäinen Phaser-peli</a><br>
<a href="http://m3156.pages.labranet.jamk.fi/ttos0700-peliohjelmointi/harkka3/samson/">Harkka 3 - Dick on the Beach (state 0 - 3)</a>
<a href="http://m3156.pages.labranet.jamk.fi/ttos0700-peliohjelmointi/harkka3/samson/">Harkka 3 - Udemy Phaser kurssi (state 0 - 8)</a>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment