iTorque2D - script programming problem
by Brian E Charapata · in Technical Issues · 08/22/2011 (7:58 am) · 2 replies
I'm building a small test 2D game for the iPhone. I've been progressing well learning the iTorque2D demo's and posts. Lately though I've hit a road block on some mechanic's I cannot seem to surmount.
Game: Dropping marbles part 1.
Description: Set in Portrait. Six marbles each a different color. These marbles drop from the top, off screen and slide down five straight columns on screen, one marble in one column at a time. I have 35 mapped places, 7 per column times 5 columns, where these marbles can stop. They always stop at the lowest open spot per column. There is more to the game but this is what I have built so far.
Not sure if I'm doing this right but here is what I have. I have six marbles, each marble a different color, in stacks located at each of the 35 mapped stopping locations. These stacks are invisible. Then the random dropping marble passes over these stacks causing collisions. I use onLevelLoaded to move the "collisionObject" class marble stacks from off screen to the 35 mapped locations on screen. I use onLevelLoaded to start the dropping "marble" class down a random column heading to the bottom of the screen passing over these 35 mapped locations. I use onCollision to make a marble in the lowest stack turn visible doing a color compare and matching the dropping marble color. All of this works great (if there's a better way please say so).
Problem: Once the dropping marble has a collision with the right stack, sets the color of the marble in the mapped location (which is all done in the onCollision event) how do I respawn the new random marble as a different color?
NOTE: Right now the dropping marble auto respawns with the same color. All six colors of marbles are different mapped sprites.
Do I need a stack of falling marbles, one falling at a time, and somehow start a different color marble falling for each iteration? How do I do that?
I only understand the two events to use, onLevelLoaded and onCollision. Are there others I can use on a marble object to trigger events?
Thanks in advance - Brian
Game: Dropping marbles part 1.
Description: Set in Portrait. Six marbles each a different color. These marbles drop from the top, off screen and slide down five straight columns on screen, one marble in one column at a time. I have 35 mapped places, 7 per column times 5 columns, where these marbles can stop. They always stop at the lowest open spot per column. There is more to the game but this is what I have built so far.
Not sure if I'm doing this right but here is what I have. I have six marbles, each marble a different color, in stacks located at each of the 35 mapped stopping locations. These stacks are invisible. Then the random dropping marble passes over these stacks causing collisions. I use onLevelLoaded to move the "collisionObject" class marble stacks from off screen to the 35 mapped locations on screen. I use onLevelLoaded to start the dropping "marble" class down a random column heading to the bottom of the screen passing over these 35 mapped locations. I use onCollision to make a marble in the lowest stack turn visible doing a color compare and matching the dropping marble color. All of this works great (if there's a better way please say so).
Problem: Once the dropping marble has a collision with the right stack, sets the color of the marble in the mapped location (which is all done in the onCollision event) how do I respawn the new random marble as a different color?
NOTE: Right now the dropping marble auto respawns with the same color. All six colors of marbles are different mapped sprites.
Do I need a stack of falling marbles, one falling at a time, and somehow start a different color marble falling for each iteration? How do I do that?
I only understand the two events to use, onLevelLoaded and onCollision. Are there others I can use on a marble object to trigger events?
Thanks in advance - Brian
#2
08/26/2011 (12:49 pm)
Sorry I didn't see this post earlier. I'm glad you were able to resolve the issue.
Brian E Charapata
Two Bit Studios, LLC
Anyway, I realized that hey every object imported in TGB labeled with the same object name will execute the same version of onLevelLoaded and onCollision so all I had to do was test to see which object was executing then choose the one I wanted to use.
Problem solved.