[Solved] Modify instance variable on object

Get help using Construct 2

Post » Fri Oct 04, 2013 4:41 pm

Hello !

I recently bougth Construct2 after tried it for days. I initially develop games in object oriented langages.

However i got a problem in a specific situation :
- I got a Bullet Family containing BulletLevel1/BulletLevel2/BulletLevel3
- Bullet Family and BulletLevelX got a LifeTime Instance Variable
- When a Bullet Family collide a Wall I decrease Bullet Family LifeTime (it allow me to destroy Bullets after an amount of bounces on wall)

Problem: The Bullet Family LifeTime i decrease is global to all bullets currently in the game so it decrease all Bullets LifeTime.

Question: How to modify an Object Instance Variable when we only got the Family of this Object (from an event based on this Family) ?

Thanks AnaelFavre2013-10-04 17:37:47
B
6
Posts: 3
Reputation: 408

Post » Fri Oct 04, 2013 5:06 pm

Instance variable are specific to instance of object, so there is probably something fishy with your events. Post a .capx or screenshot of events that are problematic. My wild guess: There is a picking problem, and you are not referring the instance you want to decrease in lifetime properly.
B
24
S
9
G
7
Posts: 756
Reputation: 7,292

Post » Fri Oct 04, 2013 5:33 pm

You're right, it was a picking problem.

I didnt find any doc about Family Instance Variable and i though that if we modify Instance Variable using a picked Family it modify the global Instance Variable common to all Children Objects of this Family but it was a mistake that came from elsewhere ...

Thanks I learn more and more about Construct2, Geat tool :)
B
6
Posts: 3
Reputation: 408


Return to How do I....?

Who is online

Users browsing this forum: ksiads, marc254, marcinkowski, mtnboy22, Rable and 4 guests