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 LazerFriends

I'm converting to Box2D Sugar, and my player entity won't move if left idle for a second.

If you press the movement keys right away, it moves just fine, but won't if you let go for a second.

I have a feeling its something very simple, so apologies for the n00b question.

Here's the link: http://bsmallbeck.com/impact/

Here's the code:


ig.module( 
	'game.entities.player' 
)
.requires(
    	'impact.entity',
	'plugins.joncom.box2d.entity'
)
.defines(function(){
 
EntityPlayer = ig.Entity.extend({
    
    size: {x:34, y:56},
    offset: {x: 1, y: 14},
    
    maxVel: {x: 200, y: 250},
	
    type: ig.Entity.TYPE.A,
    checkAgainst: ig.Entity.TYPE.NONE,
    collides: ig.Entity.COLLIDES.NEVER,
    
    animSheet: new ig.AnimationSheet( 'media/player.png', 36, 72),
    
    flip: false,
    
    zIndex:2,
	
    isFixedRotation:true,

    
    init: function( x, y, settings){
        this.parent(x,y,settings);
        
        this.addAnim( 'idle', 1, [0]);
	this.addAnim( 'run', .11, [1,2,3,4,5,6,7,8] );
	this.addAnim( 'jump', 1, [9] );
	this.addAnim( 'fall', 1, [9] );	
    },
    
    update: function(){
        if( ig.input.state('forward')){
                this.vel.x += 200;
                this.flip = false;
                
        } else if( ig.input.state('back')){
                this.vel.x -= 200;
                this.flip = true;
                
        } else {
                this.vel.x = 0;    
        }

	if( this.vel.y < 0 ) {
		this.currentAnim = this.anims.jump;
	}
	else if( this.vel.y > 0 ) {
		this.currentAnim = this.anims.fall;
	}
	else if( this.vel.x != 0 ) {
		this.currentAnim = this.anims.run;
	}
	else {
		this.currentAnim = this.anims.idle;
	}
	
	this.currentAnim.flip.x = this.flip;

	this.parent();
    }
    
 });

});

1 decade ago by Joncom

No matter how long I wait, your player moves fine when I hit the arrows.
I don't seem to have the problem you're having?

By the way, you have:
.requires(
    'impact.entity',
    'plugins.joncom.box2d.entity'
)

but only the one is needed, like this:
.requires(
    'plugins.joncom.box2d.entity'
)

1 decade ago by LazerFriends

My apologies, I went in a different direction (picking up the crates instead of pushing them) so I decided against using Box2d for now.
Page 1 of 1
« first « previous next › last »