1 decade ago by rootbeerking
				Hello everyone. I have a couple new questions. 
Question 1: I'm working on my player movement, for a 2D platformer, and I've gotten it just about perfect, only trouble is I can't seem to find a way to stop my character from sliding when turning quickly. I think it has something to do with friction(which I've set to friction: {x: 10000, y:0} ) , however it says in the documentation that the set friction only comes into play when accel is at 0, so I'm not too sure... Long story short: I basically want the character to keep it's accel, but not slide like it's on ice when changing directions quickly.
Player Movement Code:
Question 2: I'm having some issues getting shadows working correctly. First o' all, I've gotten it to follow the player, however it lags behind the character a little bit like it isn't connected to the character at all, the character will move and then the shadow will move like half a second later.
Also, I'd like to make it so the shadow stays on the ground when the player is jumping, but I'm not sure how to go about that.
Lastly, I can't seem to make the shadow disappear when the player dies. Here is what I'm using for the shadow code(in main.js update before this.parent();):
Sorry for asking so many questions at once, but I thought it'd be better than making a separate topic for each question. Any help would be much appreciated.
Oh and if it helps here is my game so far: http://www.dashproject.com/RBKtestgame/index.html
Thank you for taking the time to read this.
		Question 1: I'm working on my player movement, for a 2D platformer, and I've gotten it just about perfect, only trouble is I can't seem to find a way to stop my character from sliding when turning quickly. I think it has something to do with friction(which I've set to friction: {x: 10000, y:0} ) , however it says in the documentation that the set friction only comes into play when accel is at 0, so I'm not too sure... Long story short: I basically want the character to keep it's accel, but not slide like it's on ice when changing directions quickly.
Player Movement Code:
if( ig.input.state('left') ) {
			(ig.input.state('right') == true) ? this.accel.x = 0 : this.accel.x = -400;    
		}
		else if( ig.input.state('right') ) {
			(ig.input.state('left') == true) ? this.accel.x = 0 : this.accel.x = 400;
		}
		else {
			this.accel.x = 0;
		}
Question 2: I'm having some issues getting shadows working correctly. First o' all, I've gotten it to follow the player, however it lags behind the character a little bit like it isn't connected to the character at all, the character will move and then the shadow will move like half a second later.
Also, I'd like to make it so the shadow stays on the ground when the player is jumping, but I'm not sure how to go about that.
Lastly, I can't seem to make the shadow disappear when the player dies. Here is what I'm using for the shadow code(in main.js update before this.parent();):
if( this.player ) {
        this.shadow.pos.x = this.player.pos.x;
        this.shadow.pos.y = this.player.pos.y;
    }
    else {
	this.shadow.kill();
    }
Sorry for asking so many questions at once, but I thought it'd be better than making a separate topic for each question. Any help would be much appreciated.
Oh and if it helps here is my game so far: http://www.dashproject.com/RBKtestgame/index.html
Thank you for taking the time to read this.
