ForumsProgramming ForumHelp! How to do Slope Detection in Flash, AS2

1 5623
Toughluck
offline
Toughluck
2 posts
Nomad

What's the Actionscript for Slope Detection in Flash? I've looked everywhere but couldn't find anything!

I have 2 movieclips, the player and the ground which is sloped.

Thanks for the help!

  • 1 Reply
driejen
offline
driejen
486 posts
Nomad

Have you tried:

startHeight = //insert height of slope on the left
endHeight = //insert height of slope on the right
gradient = (endHeight - startHeight) / slope._width

dynHeight = startHeight + (player._x - slope._x) * gradient
if( player.hitTestObject(slope) && player._y < dynHeight + slope._y ){
//insert code here
}

Excuse me if I have used the wrong syntax, havent used flash for a short while.

Showing 1-1 of 1