Forum Topic: Shape flag?

(192 views • 13 replies)

This topic is 1 page long.

<< < > >>
None

micky315

Reply To Post Reply & Quote

Posted at: 5/2/09 06:47 PM

micky315 DARK LEVEL 11

Sign-Up: 08/02/07

Posts: 880

how do i use shape flag?


None

Blue-Devil23

Reply To Post Reply & Quote

Posted at: 5/2/09 07:17 PM

Blue-Devil23 EVIL LEVEL 13

Sign-Up: 09/04/05

Posts: 55

You need to be more speific


None

Saza

Reply To Post Reply & Quote

Posted at: 5/2/09 07:37 PM

Saza LIGHT LEVEL 15

Sign-Up: 10/01/05

Posts: 1,944

At 5/2/09 07:17 PM, Blue-Devil23 wrote: You need to be more speific

Shape Flash hitTesting - maybe it's that


None

Paranoia

Reply To Post Reply & Quote

Posted at: 5/2/09 08:34 PM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,697

At 5/2/09 07:17 PM, Blue-Devil23 wrote: You need to be more speific

I get the gist of what he's saying :/

The syntax for a shapeFlag hitTest is just:

AS2:

hitTest(x:Number, y:Number, shapeFlag:Boolean);

AS3:

hitTestPoint(x:Number, y:Number, shapeFlag:Boolean);

In each case, the x and y values represent a point (annoyingly in the main stage co-ordinate system, so either translation or a method like localToGlobal are needed if you're using co-ordinates in the reference frame of another object).

shapeFlag should be set to true if you want the collision detection to be against the actual shape. Setting it to false does the detection against the clip's bounding box (rectangle) instead, providing a performance increase where accuracy isn't required (although I believe an object-to-object detection may outperform it).

BBS Signature

None

micky315

Reply To Post Reply & Quote

Posted at: 5/3/09 08:47 AM

micky315 DARK LEVEL 11

Sign-Up: 08/02/07

Posts: 880

In each case, the x and y values represent a point (annoyingly in the main stage co-ordinate system, so either translation or a method like localToGlobal are needed if you're using co-ordinates in the reference frame of another object).

shapeFlag should be set to true if you want the collision detection to be against the actual shape. Setting it to false does the detection against the clip's bounding box (rectangle) instead, providing a performance increase where accuracy isn't required (although I believe an object-to-object detection may outperform it).

can you explain a little further? what does booleen mean? do i just type in numbers for x and y or is there something else? can i have an example?


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 5/3/09 09:54 AM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

well the x is any x point. it can even be a variable. the most common for both x and y is some type of object's x and y

EG
obj1.hitTest(obj2._x, obj2._y, shapeflag:Boolean)

you can even do maths in there

EG
obj1.hitTest(obj2._x-50, obj2._y+10, shapeflag:Boolean)
this is usually used for if the char's feet arent at the cross hair.

The Boolean

a boolean is a variable that is either true or false

in this case, if its true it tests on obj1's shape, if its false, it cheaks on obj1's bounding box.

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

PCpr0gramer

Reply To Post Reply & Quote

Posted at: 5/3/09 10:00 AM

PCpr0gramer NEUTRAL LEVEL 15

Sign-Up: 02/04/06

Posts: 316

It allows you to test a single point against a shape. It's useful for shapes that aren't squares, like circles or other oddies. The format is this (assume the object to be tested is a circle, and we're testing it against the x and y position of a bullet.)

if(circle.hitTest(bullet._x, bullet._y, true)){
}

That's for AS2.


None

micky315

Reply To Post Reply & Quote

Posted at: 5/3/09 12:09 PM

micky315 DARK LEVEL 11

Sign-Up: 08/02/07

Posts: 880

I WANT TO CHECK IF THE CHARS FEET ARE TOUCHING THE GROUND MC sry cpas

heres wat you ave me (changed the names)
if(char.hitTest(ground._x, bullet._y, true)){
}

do i have to change the x or y?


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 5/3/09 12:19 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

At 5/3/09 12:09 PM, micky315 wrote: heres wat you ave me (changed the names)
if(char.hitTest(ground._x, bullet._y, true)){
}

No. First off, u used char, ground And bullet? second off, this is saying (assuming u ment ground when u said bullet) that your testing your char mc to one point on the ground.

and lastly, remember, the cross hair is 0,0 on the coordinate system

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

Paranoia

Reply To Post Reply & Quote

Posted at: 5/3/09 12:19 PM

Paranoia DARK LEVEL 34

Sign-Up: 04/22/05

Posts: 9,697

At 5/3/09 12:09 PM, micky315 wrote: I WANT TO CHECK IF THE CHARS FEET ARE TOUCHING THE GROUND MC sry cpas

heres wat you ave me (changed the names)
if(char.hitTest(ground._x, bullet._y, true)){
}

Umm... You don't seem to have any idea what you're supposed to be doing there. Try re-reading... well, everything.

BBS Signature

None

micky315

Reply To Post Reply & Quote

Posted at: 5/3/09 04:06 PM

micky315 DARK LEVEL 11

Sign-Up: 08/02/07

Posts: 880

heres wat you ave me (changed the names)
if(ground.hitTest(char._x=0, char._y=0, true)){
}
ok how bout this then


None

Yambanshee

Reply To Post Reply & Quote

Posted at: 5/3/09 11:59 PM

Yambanshee DARK LEVEL 11

Sign-Up: 10/05/08

Posts: 1,607

no need for the =0. Just read what i said in my explaination. My examples are working perfectly!

AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature

None

KaynSlamdyke

Reply To Post Reply & Quote

Posted at: 5/4/09 05:29 AM

KaynSlamdyke LIGHT LEVEL 16

Sign-Up: 06/25/04

Posts: 4,926

At 5/3/09 12:09 PM, micky315 wrote: I WANT TO CHECK IF THE CHARS FEET ARE TOUCHING THE GROUND MC sry cpas

Why on earth would you post this? Does your backspace not work? Refresh button on the fritz? Only able to type a given sentance once without revision lest a collar around your neck explode Battle Royale style?

Current build for ThreedeeTiles : Monkey
Previous: Lamprey, Mountain Goat (Dead Fork)


None

henke37

Reply To Post Reply & Quote

Posted at: 5/4/09 05:45 AM

henke37 NEUTRAL LEVEL 23

Sign-Up: 09/10/04

Posts: 3,666

If you don't know what you are collision testing, you don't know what you are doing. Not knowing what you are doing can't lead to good results.

Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


All times are Eastern Standard Time (GMT -5) | Current Time: 07:44 PM

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