Planet like gravity
markfirman
Member, BASIC Posts: 18
Hi all, I was wondering if someone could point me in the right direction. To put things into context - I'll explain the basics of my app.
I have a canvas, whereby the user can "place" atoms (such as hydrogen). When the user selects the hydrogen tool, and touches the screen a new actor called 'Hydrogen' is spawned at touch X and Y locations.
This hydrogen actor is programmed to essentially vibrate and wonder around the canvas until it interacts with another atom.
What I want to achieve is; when two atoms collide, one is destroyed whilst the other adjusts its size to reflect two atoms merging into one. I cannot seem to achieve this..
All hydrogen atoms spawned derive from the same actor..
Thanks in advance,
Mark.
EDITED FOR CLARITY
Comments
I should have clarified; the atoms colliding are the same actor and so how could I tell one to destroy itself but keep one alive?
You could have two SEPARATE atoms that act the same in every way except one is to be destroyed and the other to grow.
I'm afraid that wouldn't work. As what if the two atoms that collide are not separate actors and as such both are destroyed, or both get bigger. I cannot determine which atoms will or won't collide.
This seems like a non sequitur to me ? The question seems to be 'how do I create a gravity field - because I need two atoms to collide, leaving only one' ?
The two parts of the question don't seem related in any way ?
Ok - I may have not explained the question very well. Ignore the first gravity bit - I have managed to get this working. The second part is still relevant though. When I have multiple actors on-screen that are essentially duplicates of each other - when they collide, how can I make one grow and the other to be destroyed.
You just need to employ any system that generates a switch, so when the atoms collide the switch is thrown, this is what generates the merged atom, so it doesn't matter if the switch is turned on once, twice or multiple times, it always returns a single universal result . . . does that make sense, hold on I'll make a very quick demo . . .
Example attached
Thank-you very much for your help - from this I'll be able to continue with development. Thanks again.
Two hydrogen atoms colliding would create helium so wouldn't you destroy both and spawn a new stable particle?
Complete Guide to iOS Publishing {} Complete Guide to Mac Publishing
I bet if you get it just right you can achieve the same effect by destroying/spawning after a random interval, leveraging GameSalad's code cycles. (Probably insane to try, though )
Contact me for custom work - Expert GS developer with 15 years of GS experience - Skype: armelline.support