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 alexandre

From this post, in which ThatAnalog asks:
I want the user to be able to tap the button for a small jump,
and hold it down for a bigger one

Here's one (tested) way:
jump: 200,
jumpX: 0,    // jump extender

update: function()
{
    if (ig.input.pressed('jump') && this.standing)
    {
        this.vel.y = -this.jump;
        this.jumpX = 1;
    }

    if (ig.input.state('jump'))
    {
        this.vel.y -= this.jump*0.1*this.jumpX;
        this.jumpX = (this.jumpX > 0.1 ? this.jumpX*0.95 : 0);
    }

    this.parent();
}

1 decade ago by paulh

quick draw mc alexandre!

What is the ? used for, difficult symbol to search for in google!

1 decade ago by stahlmanDesign

The ? is s a fast way of writing an if statement.
var a = true;
a == true ? do_if_true() : otherwise_do_this();

is the same as 

var a = true;
if (a == true){
    do_if_true();
}else{
     otherwise_do_this();
}

1 decade ago by paulh

Thanks!
Page 1 of 1
« first « previous next › last »