Be a Supporter!

hitTest problems

  • 343 Views
  • 6 Replies
New Topic Respond to this Topic
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
hitTest problems 2009-02-04 10:59:17 Reply

can someone have a look at the engine im making right now?
SWF<<<
code:

if (bg_mc.hitTest(car_mc._x-80, car_mc._y, true)) {
		if (speed<0) {
			speed = -speed;
		}
	} else if (bg_mc.hitTest(car_mc._x+200, car_mc._y, true)) {
		if (speed>0) {
			speed = -speed;
		}
	}

bg_mc is the black line, car_mc is the car and speed is the speed at which the car moves.
as you might be able to see, despite hitting fine on the left wall (sorta) the nose doesint sence the rest of the walls. Im using AS2 Flash8.


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

BBS Signature
Super-Yombario
Super-Yombario
  • Member since: Mar. 16, 2007
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to hitTest problems 2009-02-04 11:07:20 Reply

I hope you already know how much of a pain it is with so little handling/speed and such a large car :/
But you've gotten farther in Car hitTests than I so I can't really help.

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to hitTest problems 2009-02-04 11:10:40 Reply

its only a basic engine, resizing, handling, speed ect.. are all one variable changes!


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

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to hitTest problems 2009-02-04 12:11:37 Reply

can anyone Really good with hittests Pm me about
This


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

BBS Signature
regulargabs
regulargabs
  • Member since: Feb. 5, 2004
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to hitTest problems 2009-02-04 12:21:08 Reply

The simplest solution would be to make 4 points inside the car mc (like a rectangle boulding box), then use localToGlobal so you get their positions on stage, then you use the 4 points to hittest.


wibble wabble

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to hitTest problems 2009-02-04 12:27:58 Reply

no idea how to do that =/


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

BBS Signature
Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to hitTest problems 2009-02-04 12:36:34 Reply

no idea how to use localToGlobal atlest... Ill just make 4 normal shapeFlag hitTests


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

BBS Signature