View Full Version : [AS2] Stick AI
PhatKitty
02-21-2009, 02:24 AM
Solved
I still need to fix this bit:
onClipEvent (enterFrame) {
if (this.hitTest(_root.char)) {
touchingchar = true;
} else {
touchingchar = false;
}
I want to make it so it hit tests 20 pixels either side of my char, so something like char+20 or char._x+20, but I don't know what.
PhatKitty
02-21-2009, 03:08 AM
And another thing before I go to sleep, how do I make something happen when 2 movie clips y co-ordinates are the same so like:
if (two y co-ords are the same) {
grav = maxJump;
// this means jump
}
I need to know the "two y co-ords are the same" bit (duh) so any help ontop of the original quetion would be appreciated ^-^
bluemagica
02-21-2009, 09:12 AM
1) use hitTest(x,y,shapeflag), this way you can say x+20 or x-20! also look into distance checking, google it! (hint: x2-x1,y2-y1)
2) if(something._y==another._y){do something}
PhatKitty
02-21-2009, 02:56 PM
I need an explanation of how to use shapeflag, all the google results just tell you what you already know "Shapeflag, when it's true means it only tests the actual object" I need to know how to ues it, I don't really care what it does in detail... I tryed this bit it just failed:
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
this._x += 10;
}
if (Key.isDown(Key.LEFT)) {
this._x -= 10;
}
if (Key.isDown(Key.UP)) {
this._y -= 10;
}
if (Key.isDown(Key.DOWN)) {
this._y += 10;
}
if (wall.hitTest(x, y, true)) {
gotoAndStop(2);
}
}
This isn't my game, just a test with a box called "boxy" and a wall called "wall". All this is inside the MC "boxy".
kkbbcute
02-21-2009, 03:06 PM
Are you sure that your X and Y are correct, are you using AS2 or 3 (I assume not 1), maybe it should be this._x and this._y, care to give a source file?
PhatKitty
02-21-2009, 03:31 PM
That was just one of the 20 odd things I tried, like _x _y, i did this._x this._y and wall._x wall._y, all to no avail.
And how do I attach a .fla?
kkbbcute
02-22-2009, 03:58 AM
That was just one of the 20 odd things I tried, like _x _y, i did this._x this._y and wall._x wall._y, all to no avail.
And how do I attach a .fla?
You ZIP up the file and attach it by clicking on the paper click looking button while posting. And what AS version are you using again?
cjx3711
02-22-2009, 06:47 AM
And another thing before I go to sleep, how do I make something happen when 2 movie clips y co-ordinates are the same so like:
if (two y co-ords are the same) {
grav = maxJump;
// this means jump
}
I need to know the "two y co-ords are the same" bit (duh) so any help ontop of the original quetion would be appreciated ^-^
for that part, you just put this:
Asuming objects are called obj1 and obj2
if (obj1._y == obj2._y) {
grav = maxJump;
// this means jump
}
cjx3711
02-22-2009, 06:48 AM
You ZIP up the file and attach it by clicking on the paper click looking button while posting. And what AS version are you using again?
And judging by the code, I would think AS2 and most likely not AS3 or AS1
kkbbcute
02-22-2009, 07:16 AM
And judging by the code, I would think AS2 and most likely not AS3 or AS1
That's exactly why I'm asking, maybe he set his AS options wrongly or something. That's why the file is not working.
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.