Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

hitTest with diagonal lines

Status
Not open for further replies.

eninen393

Programmer
Apr 17, 2006
5
US
i am creating a flash game and i can stop the caharacter from crossing lines but when i use diagonal lines, the character stops at the blue box seounding it.

i thought it would work but i need to know how to shrink the blue box that is created when you make a movie clip.

please help
----------CODE------------------------

onClipEvent (load) {
this._visible = false;
}
onClipEvent (enterFrame) {
if (this.hitTest(_root["stanD"])) {
_root["stanD"]._y -= _global.speed;
_root["stanD"]._x += _global.speed;
}
if (this.hitTest(_root["blob"])) {
_root["blob"]._y -= _global.moveSpeed2;
_root["blob"]._x += _global.moveSpeed2;
}
if (this.hitTest(_root["gEnemy"])) {
_root["genemy"]._y -= _global.gEnemySpeed;
_root["genemy"]._x += _global.gEnemySpeed;
}
}
 
like this becuase this doesn't work and the code is in the line movie clip not the character movie clip.

-------CODE-----------
if (this.hitTest(_global.charX, _global.charY, true)) {
_root["stanD"]._y -= _global.speed;
_root["stanD"]._x += _global.speed;
}
 
if (_root["stanD"].hitTest(this._x+20, this._y, true))

all that this does is create a single dot that the _root["stanD"] can't cross the dot is 20 pixels to the right of the start of the movieClip.

any one know how to make the dot into a line or something?

any ideas or thoughts are greatly appreciated!

thanks,
nick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top