Be a Supporter!

Shape flag?

  • 763 Views
  • 13 Replies
New Topic Respond to this Topic
micky315
micky315
  • Member since: Aug. 2, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Shape flag? 2009-05-02 18:47:07 Reply

how do i use shape flag?


...

BBS Signature
Blue-Devil23
Blue-Devil23
  • Member since: Sep. 4, 2005
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Shape flag? 2009-05-02 19:17:36 Reply

You need to be more speific

Sam
Sam
  • Member since: Oct. 1, 2005
  • Offline.
Forum Stats
Moderator
Level 19
Programmer
Response to Shape flag? 2009-05-02 19:37:08 Reply

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

Shape Flash hitTesting - maybe it's that

Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to Shape flag? 2009-05-02 20:34:43 Reply

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
micky315
micky315
  • Member since: Aug. 2, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 08:47:35 Reply

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?


...

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 09:54:29 Reply

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
PCpr0gramer
PCpr0gramer
  • Member since: Feb. 4, 2006
  • Offline.
Forum Stats
Member
Level 15
Blank Slate
Response to Shape flag? 2009-05-03 10:00:14 Reply

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.

micky315
micky315
  • Member since: Aug. 2, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 12:09:45 Reply

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?


...

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 12:19:34 Reply

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
Paranoia
Paranoia
  • Member since: Apr. 22, 2005
  • Offline.
Forum Stats
Member
Level 35
Game Developer
Response to Shape flag? 2009-05-03 12:19:51 Reply

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
micky315
micky315
  • Member since: Aug. 2, 2007
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 16:06:41 Reply

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


...

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to Shape flag? 2009-05-03 23:59:11 Reply

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
KaynSlamdyke
KaynSlamdyke
  • Member since: Jun. 25, 2004
  • Offline.
Forum Stats
Member
Level 16
Melancholy
Response to Shape flag? 2009-05-04 05:29:57 Reply

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?


...

BBS Signature
henke37
henke37
  • Member since: Sep. 10, 2004
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to Shape flag? 2009-05-04 05:45:02 Reply

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.