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 salsa

Hey guys, I use a video tutorial to create my first game, but i have a question...

In my game page i put a button with a jquery event, and i try to move a entity player...
but when i click that entity dont move...

anybody knows how i can set a entity position clicking on button?

i try:

ig.module( 
    'game.entities.main-player' 
).requires(
    'game.entities.player'
).defines(function(){
    EntityMainPlayer = EntityPlayer.extend({
        
        animSheet: new ig.AnimationSheet('media/player.png', 32, 32),
        
        moveTest: function(){
            this.vel.x = 100;
        },
        
        update: function(){
            if (ig.input.state('up')){
                this.vel.y = -100;
            } else if (ig.input.state('down')){
                this.vel.y = 100;
            } else if (ig.input.state('left')){
                this.vel.x = -100;
            } else if (ig.input.state('right')){
                this.vel.x = 100;
            } else {
                    this.vel.y = 0;
                    this.vel.x = 0;
            }
            
            this.parent();
        }
        
    });

});

jquery event:

$(function(){
    $('#ns').click(function(){
        EntityMainPlayer.moveTest;
    });
});

thanks :)

1 decade ago by salsa

ok im done...

    $('#ns').click(function(){
        var player = ig.game.getEntitiesByType(EntityMainPlayer)[0];
        player.pos.x = player.pos.x + 100;
        player.pos.y = player.pos.y + 100;
    });

;)
Page 1 of 1
« first « previous next › last »