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 Jon

Hello,

I am trying to increase the size of a ball after a user clicks on it.

I am spawning multiple balls at once with the following:

ballOne = ig.game.spawnEntity('EntityBall', 75, 250);
ballTwo = ig.game.spawnEntity('EntityBall', 75, 150);

The EntityBall is just a simple entity that specifies the animSheet (the ball is spinning which is why I didn't use an image). I am able to successfully create the two balls from the above code.

However, now I want to allow the user to click on one of the balls and the size of that ball to increase.

After searching these forums for a while I cannot seem to find a way to do this. I have tried doing stuff like:

radius = Math.random().map(0, 1, 20, 50).round();
ballOne.size={x:radius, y:radius};

But nothing changes. I figured this was going to be the easier part of my little project :) I guess I am wrong once again.

Any tips on increasing the size of the animation?

1 decade ago by Joncom

I went to http://playbiolab.com/ and started the game.

I then opened console, and typed:
ig.game.getEntitiesByType(EntityPlayer)[0].size;

...which returned: {x:16, y:14}

I then typed in console:
ig.game.getEntitiesByType(EntityPlayer)[0].size = {x:32, y:28};

This changed the size of the entity, much like you are doing.

This had no effect on the entities appearance, however it DID affect how the entity collided with the surroundings.

So, are you sure your code isn't working? Maybe it is, but you simply haven't adjusted the appearance for the new size.

1 decade ago by Jon

Looking a little deeper into the .size...the edges of the collisions were extended like you said Joncom.

However, I still need the entity's appearance to be enlarged as well. Is there something that I am not updating correctly that will help me accomplish this?

1 decade ago by Joncom

I've not played with this myself, but it appears to be what you are looking for.

1 decade ago by Jon

Reading through it quickly (as I am at work) this does seem to be exactly what I need.

Thanks for the help, Joncom!
Page 1 of 1
« first « previous next › last »