Forum Topic: hittest ~ hits entire movieclip

(635 views • 37 replies)

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
None

teenagegluesniffer

Reply To Post Reply & Quote

Posted at: 2/28/06 07:49 PM

teenagegluesniffer EVIL LEVEL 09

Sign-Up: 02/20/06

Posts: 331

*cough* *achoo* help?


None

teenagegluesniffer

Reply To Post Reply & Quote

Posted at: 3/1/06 12:55 AM

teenagegluesniffer EVIL LEVEL 09

Sign-Up: 02/20/06

Posts: 331

:( Can anyone help with this problem?


None

teenagegluesniffer

Reply To Post Reply & Quote

Posted at: 3/1/06 02:39 AM

teenagegluesniffer EVIL LEVEL 09

Sign-Up: 02/20/06

Posts: 331

I'm sorry, I know I just bumped this. But this recent problem is bugging the crap out of me!
What am I missing here that is making this not work!?

onClipEvent(enterFrame)
{
var ox=_x, oy = _y;

if(Key.isDown(Key.RIGHT))
{
_x+=4;
}
if(Key.isDown(Key.LEFT))
{
_x-=4;
}
if(Key.isDown(Key.DOWN))
{
_y+=4;
}
if(Key.isDown(Key.UP))
{
_y-=4;
}
for (i=0; i<100; i++) {
if (_root["object"+i].hitTest(_root.char._x,_
root.char._y,true)) {
_x=ox; _y=oy;
}
}

for (i=0; i<100; i++) {
if (_root["enemy"+i].hitTest(_root.char._x,_r
oot.char._y,true)) {
_x=ox; _y=oy;
}
}
}

Help please! :(


None

Chrispington

Reply To Post Reply & Quote

Posted at: 3/1/06 05:44 AM

Chrispington EVIL LEVEL 31

Sign-Up: 07/02/04

Posts: 1,247


None

MadGiraffe

Reply To Post Reply & Quote

Posted at: 3/1/06 06:08 AM

MadGiraffe NEUTRAL LEVEL 10

Sign-Up: 01/07/05

Posts: 1,350

At 3/1/06 05:44 AM, Chrispington wrote: this helped me out a lot.

Woa, thanks Chrispington! Good tut.


None

teenagegluesniffer

Reply To Post Reply & Quote

Posted at: 3/1/06 11:02 AM

teenagegluesniffer EVIL LEVEL 09

Sign-Up: 02/20/06

Posts: 331

Thank you! That was what I needed.
"All actionscript are included in the right one. " That is what made it click. ;) Thank you1


None

Juice-Tin

Reply To Post Reply & Quote

Posted at: 3/1/06 11:14 AM

Juice-Tin LIGHT LEVEL 06

Sign-Up: 02/03/01

Posts: 752

At 2/28/06 01:12 AM, teenagegluesniffer wrote: for (i=0; i<100; i++) {
if (_root["object"+i].hitTest(_root.char._x,_
root.char._y,true)) {
_x=ox; _y=oy;
}
}

for (i=0; i<100; i++) {
if (_root["enemy"+i].hitTest(_root.char._x,_r
oot.char._y,true)) {
_x=ox; _y=oy;
}
}

you should group up your loops when ever you can.

for (i=0; i<100; i++) {
if (_root["object" + i].hitTest(_root.char._x, _root.char._y, true) || _root["enemy"+i].hitTest(_root.char._x, _root.char._y, true)) {
_x=ox; _y=oy;
}
}

this way it does the same thing, and only has to loop 100 times, instead of 200.
does the same thing with less of the mess.


None

Juice-Tin

Reply To Post Reply & Quote

Posted at: 3/1/06 11:19 AM

Juice-Tin LIGHT LEVEL 06

Sign-Up: 02/03/01

Posts: 752

At 3/1/06 05:44 AM, Chrispington wrote: http://www.sothink.c..7011c64d50a01ccf7ba3



this helped me out a lot.

oh nice, very good use of prototype. I never would have thought of that


All times are Eastern Standard Time (GMT -5) | Current Time: 12:54 PM

<< Back

This topic is 2 pages long. [ 1 | 2 ]

<< < > >>
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!