Nicky -> RE: Flash Q&A Thread 5 - Flash Has Shares In Your Soul (9/16/2008 2:21:14)
|
Hey- me back again :P. Okay, simple question here. First of all a little background information just in case you're not sure what the code even IS XD. Well, first of all I got this code from a tutorial which conveniently didn't explain the code it used. Basically, it's a maze thingy, and I have an mc called walls with a drawing of my walls in it. The actual code below goes into my MC which is my character. The code is basically a collision detection between the character and the walls MCs. The var myBounce is the speed at which the character moves. Now, it works and I've gathered that it basically gets co-ordinates of my walls MC's edges or something, but that's about it. So if someone could explain this code below, that would be great!: if (_root.walls.hitTest(getBounds(_root).xMax, _y, true)) {
_x -= myBounce;
}
if (_root.walls.hitTest(getBounds(_root).xMin, _y, true)) {
_x += myBounce;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMax, true)) {
_y -= myBounce;
}
if (_root.walls.hitTest(_x, getBounds(_root).yMin, true)) {
_y += myBounce;
} If you need anything extra, like my fla or something if you don't understand from my explanation at the top that's cool. Don't worry about rushing or anything, just for future reference I'd like to know what the code in my MC does :P. Thanks!
|
|
|
|