00:00
00:00
HeroPower
Been teaching myself programming since the start of 2014. Making simple games for now but as my knowledge grows so will my projects!

Age 37, Male

Indie Game Dev

Oregon

Joined on 12/13/05

Level:
25
Exp Points:
6,770 / 6,940
Exp Rank:
6,086
Vote Power:
6.69 votes
Art Scouts
3
Rank:
Police Officer
Global Rank:
10,922
Blams:
326
Saves:
533
B/P Bonus:
10%
Whistle:
Normal
Trophies:
1
Medals:
579
Supporter:
2y 2d

2 days....

Posted by HeroPower - May 1st, 2014


Two days spent trying to learn Arrays and Loops....

I kinda grasp the loops...well...I've only learned the "for" loop. Still have to look into the other types.

And I kinda grasp the Arrays and all it's properties.

But when I go to make use of it in a game test project it all goes to hell. Trying to access coins on the stage (pre-existing in a MC container that was added to the stage). Think old school Mario. If, for example, the level had 100 coins it would be like 300 lines of code to call a function for each instance name of the coin. I know their must be a way to target each coin MC individually using Arrays and Loops. I just don't know how to do it if they are already on stage because they were inside an container MC I added to the stage ( I don't want to addChild every damn coin individually to the container).

Blah...blah....bitch....bitch....

I'll try again tomorrow. It's late and I have a long ass class tomorrow.

Odds are I'll see you peeps in the forums soon.


Comments

DisplayObjectContainer --> getChildAt

Wouldn't that only grab one instance of the coin? If I add my level container to the stage and its display list was (for example) background, player, coin, coin, coin: wouldn't container.getChildAt(3) just grab a single coin? Maybe I'm missing a step on what to do after this....

DisplayObjectContainer --> numChildren

I like that your giving me short answers to make me work for understanding it. Something is just not clicking with me.

With my previous example in my previous response: container.numChildren would be 5. Doing container.getChildAt (2 or 3 or 4) would show one of the coins...

I feel like I'm missing something to glue this all together. I know doing numChildren will show me everything in that containers display list which then allows me to use getChildAt to grab one object out of it. But that's it. The only thing I've learned to do with these two things are to change the stacking order in the display list...

....and now after playing around with it more I realize I can declare a new variable and make that equal the getChildAt object and use that for hit detection....but that still is just for that one single coin and not the rest....dude I'm lost...toss me another hint...