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 mengyaoren

Hi All, my code as follows:
init: function( x, y, settings ) {
	this.animSheet = new ig.AnimationSheet( this.pet_path + this.pet + '.png', 150, 150 );
	this.addAnim( 'idle', 0.1, [0] );
	this.parent( x, y, settings );
},

how to resize the entity from 150x150 to 60x60?
thinks very much.

1 decade ago by Joncom

You can change the size of your entity any time you want.
// Grab the player entity, for example.
var player = ig.game.getEntitiesByType(EntityPlayer)[0];
player.size.x = 60;
player.size.y = 60;

Or you could set the size of the entity in your player.js
size: { x: 60, y: 60 },
init: function(x, y, settings) {
    this.parent(x, y, settings);
    ....
}

1 decade ago by mengyaoren

Where I changed the entity'size. it didn't work and still 160x160.
Quote from Joncom
You can change the size of your entity any time you want.
// Grab the player entity, for example.
var player = ig.game.getEntitiesByType(EntityPlayer)[0];
player.size.x = 60;
player.size.y = 60;

Or you could set the size of the entity in your player.js
##
size: { x: 60, y: 60 },
init: function(x, y, settings) {
this.parent(x, y, settings);
....
}
##

1 decade ago by Joncom

If you want more help, you need to provide more information.
Please post some code showing your attempt.

1 decade ago by Clyssandre

Hello,

I'm actually interested in knowing more about it. I've been trying to resize an entity AFTER initialization and the code provided by Joncom didn't seem to have the expected effect in my situation. I'm testing with the following code:

ig.module (
    'game.entities.map_game1_rollover'
)
    .requires(
    'impact.entity'
)
    .defines(function() {
        EntityMap_game1_rollover = ig.Entity.extend({
            type: ig.Entity.TYPE.B,
            animSheet:new ig.AnimationSheet( 'media/map/map1.png', 449, 291),
            size: {x:449, y:291 },
            pos: {x:264,y:108},

            init: function( x, y, settings ) {
                this.parent( x, y, settings );
                this.addAnim( 'playing', 1, [0]);
            },

            update: function() {
                this.size.x = this.size.x-1;
                this.size.y = this.size.x-1;
            }
        });
    });

Do you have any advice ? Thank you for the help !

1 decade ago by Joncom

@Clyssandre: What effect are you seeing?

By any chance where you wrote:
this.size.y = this.size.x-1; did you mean to write:
this.size.y = this.size.y-1;?

Going to assume you're seeing some change in size at least...

1 decade ago by Clyssandre

@Joncom: Thank you for your answer.

Well I simplified my code so it would be more readable for sharing and made a typo in it. I indeed intented to write: this.size.y = this.size.y-1;
Sorry about that!

In any case, no, I don't see any change at all. :)

FireBug doesn't fire any javascript error. It just looks like it's completely ignored.
Am I supposed to call a function on animSheet to resize it or something like this?
I've been searching throught impactJS documentation but couldn't figure this out.

1 decade ago by Joncom

Am I supposed to call a function on animSheet to resize it or something like this?
I thought you were trying to change the size of the entity hitbox. It's obvious now that you're talking about the animation sheet. Here, maybe this will help.
Page 1 of 1
« first « previous next › last »