Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by fugufish

anyone made a function that creates the typewriter effect similar to http://www.youtube.com/watch?v=-4DI7XPCUDo ?

the idea is to use a timer, font.draw and the run() function in main.js

1 decade ago by Hareesun

That's totally possible, but would be a pain/nightmare to get right.

The best way I can see this working is to not have it draw each letter (which'd have to be individually placed) each time the delta is a certain number, but to have it delete and replace the string each time. That's the most code-heavy, but neatest on-screen way.

But please, I'd love to be wrong :P

1 decade ago by fugufish

kinda stumped after 3 hrs.... dang anyone have any quick & dirty code?

1 decade ago by xdissent

A quick little demo:
In your game&039;s #init method:

this.fontTimer = new ig.Timer();
this.fontTimeScale = 3;

In the draw method:

var x = ig.system.width / 2,
    y = ig.system.height / 2,
    si = (this.fontTimer.delta() * this.fontTimeScale).round();
this.font.draw('It Works!'.substr(0, si), x, y, ig.Font.ALIGN.CENTER);

The speed of the effect is controlled by this.fontTimeScale (larger = faster). Does that help?

1 decade ago by rootbeerking

@xdissent I tried this for my game over screen however it didn't work.

I put in my main.js's init:
this.fontTimer = new ig.Timer();
this.fontTimeScale = 3;

and in draw I have:
var x = ig.system.width/2,
y = ig.system.height/2;
                    
if (ig.game.GameOver == true) {
si = (this.fontTimer.delta() * this.fontTimeScale).round();
this.font.draw('GAME OVER'.substr(0, si), x, y, ig.Font.ALIGN.CENTER);
}

Yet when GameOver becomes true instead of triggering the game over text on screen I get nothing. What am I doing wrong?
Page 1 of 1
« first « previous next › last »