triangle now hides while typewriting
This commit is contained in:
@@ -10,7 +10,7 @@
|
|||||||
<title>TextHorror</title>
|
<title>TextHorror</title>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body onpageshow="load()" onclick="mouseClick()">
|
<body onpageshow="load()" onmouseup="mouseUp()" onmousedown="mouseDown()">
|
||||||
<div id="bubble"></div>
|
<div id="bubble"></div>
|
||||||
<img id="triangle" src="text_horror/assets/triangle.png">
|
<img id="triangle" src="text_horror/assets/triangle.png">
|
||||||
<p class="thx-for-playing">Thanks for playing</p>
|
<p class="thx-for-playing">Thanks for playing</p>
|
||||||
|
@@ -15,20 +15,27 @@ function load() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function typeWriter() {
|
function typeWriter() {
|
||||||
if (document.getElementById("bubble").innerHTML.length - 1 < dlgLines[dlgPointer].toString().length) {
|
if (document.getElementById("bubble").innerHTML.length < dlgLines[dlgPointer].toString().length) {
|
||||||
document.getElementById("bubble").innerHTML += dlgLines[dlgPointer].toString().charAt(typeindex);
|
document.getElementById("bubble").innerHTML += dlgLines[dlgPointer].toString().charAt(typeindex);
|
||||||
typeindex++;
|
typeindex++;
|
||||||
setTimeout(typeWriter, speed);//loops because of running "typeWriter" after waiting
|
document.getElementById("triangle").hidden = document.getElementById("bubble").innerHTML.length != dlgLines[dlgPointer].length
|
||||||
|
setTimeout(typeWriter, speed); //loops because of running "typeWriter" after waiting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mouseClick() {
|
function mouseDown() {
|
||||||
if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].length) {
|
document.getElementById("triangle").hidden = true;
|
||||||
if (dlgPointer < dlgLines.length - 1) {
|
}
|
||||||
dlgPointer++;
|
|
||||||
while (!(typeof dlgLines[dlgPointer] === 'string')) dlgPointer++;//again if it's not string
|
function mouseUp() {
|
||||||
|
if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].length) { //check if text is typed out
|
||||||
|
if (dlgPointer < dlgLines.length - 1) { //check if dlgPointer is not at the array end
|
||||||
|
do
|
||||||
|
dlgPointer++;
|
||||||
|
while (!(typeof dlgLines[dlgPointer] === 'string')) //again if it's not string
|
||||||
typeindex = 0;
|
typeindex = 0;
|
||||||
document.getElementById("bubble").innerHTML = "";
|
document.getElementById("bubble").innerHTML = "";
|
||||||
|
document.getElementById("triangle").hidden = true;
|
||||||
typeWriter();
|
typeWriter();
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("bubble").hidden = true;
|
document.getElementById("bubble").hidden = true;
|
||||||
|
Reference in New Issue
Block a user