triangle now hides while typewriting
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<title>TextHorror</title>
|
||||
</head>
|
||||
|
||||
<body onpageshow="load()" onclick="mouseClick()">
|
||||
<body onpageshow="load()" onmouseup="mouseUp()" onmousedown="mouseDown()">
|
||||
<div id="bubble"></div>
|
||||
<img id="triangle" src="text_horror/assets/triangle.png">
|
||||
<p class="thx-for-playing">Thanks for playing</p>
|
||||
|
@@ -15,20 +15,27 @@ function load() {
|
||||
}
|
||||
|
||||
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);
|
||||
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() {
|
||||
if (document.getElementById("bubble").innerHTML.length == dlgLines[dlgPointer].length) {
|
||||
if (dlgPointer < dlgLines.length - 1) {
|
||||
dlgPointer++;
|
||||
while (!(typeof dlgLines[dlgPointer] === 'string')) dlgPointer++;//again if it's not string
|
||||
function mouseDown() {
|
||||
document.getElementById("triangle").hidden = true;
|
||||
}
|
||||
|
||||
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;
|
||||
document.getElementById("bubble").innerHTML = "";
|
||||
document.getElementById("triangle").hidden = true;
|
||||
typeWriter();
|
||||
} else {
|
||||
document.getElementById("bubble").hidden = true;
|
||||
|
Reference in New Issue
Block a user