Forum Topic: Hittesting with unknown names

(70 views • 5 replies)

This topic is 1 page long.

<< < > >>
None

thenoodleman-com

Reply To Post Reply & Quote

Posted at: 6/6/06 05:14 PM

thenoodleman-com NEUTRAL LEVEL 03

Sign-Up: 06/04/06

Posts: 1

Eyess... I have clip1xx and clip2xx where xx can be anything, and I want to do a hittest between them so I can destroy clip1 on contact.

Any ideas?


None

Chrispington

Reply To Post Reply & Quote

Posted at: 6/6/06 09:31 PM

Chrispington EVIL LEVEL 31

Sign-Up: 07/02/04

Posts: 1,247

Ok, the xx being anything is bad, try to limit it to between 1 - 50 or 1 - 100.

Then entr the world of for loops!

for(q=1;q<50;q++){
['clip'+q] code here!
}

the "for(q=1;q<30;q++)" will run this loop, increasing q by 1 each time it runs, until q = 50.

so it will test clip1 - 50, just refer to the clip with the Q as i have done "['clip'+q]"

make sense?

BBS Signature

None

Glaiel-Gamer

Reply To Post Reply & Quote

Posted at: 6/6/06 09:46 PM

Glaiel-Gamer NEUTRAL LEVEL 26

Sign-Up: 12/28/04

Posts: 7,063

you could push the MC's into an array then iterate through the array too


None

Pyromaniac

Reply To Post Reply & Quote

Posted at: 6/6/06 09:50 PM

Pyromaniac EVIL LEVEL 18

Sign-Up: 01/14/05

Posts: 2,968

or something like this
for (i in _root) {
if (_root[i]._name.indexOf("enemy") != -1) {
//actions
}
}

Change enemy to whatever you want.


None

Blaze

Reply To Post Reply & Quote

Posted at: 6/6/06 09:52 PM

Blaze LIGHT LEVEL 22

Sign-Up: 08/04/05

Posts: 6,957

At 6/6/06 09:50 PM, pyro111 wrote: or something like this
for (i in _root) {
if (_root[i]._name.indexOf("enemy") != -1) {
//actions
}
}

Change enemy to whatever you want.

in this case you would use:

for(i in _root){
if(_root[i]._name.indexOf("clip")!=-1){
if(_root[i].hitTest(something)){
actions;
}
}
}

Note that youd reffer to your "clips" as _root[i].


None

Pyromaniac

Reply To Post Reply & Quote

Posted at: 6/6/06 10:05 PM

Pyromaniac EVIL LEVEL 18

Sign-Up: 01/14/05

Posts: 2,968

At 6/6/06 09:52 PM, Darkfire_Blaze wrote: stuff

I figured if hes coding a game he would understand a hitTest and be able to read the code. But I guess not.


All times are Eastern Standard Time (GMT -5) | Current Time: 07:56 AM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!