PDA

View Full Version : Actionscript 2.0, problemo, OLÉ!



Tork
03-04-2010, 11:24 AM
Allright, im just trying to make a very simple game.. some mysterious man has been helping me lately, but he is offline at the moment.. and googling doesn't really help..
allirght, heres the problem, its verry simple to solve if you know what to do i geuss...
i have problems with the
-hitTest <-- has got to do with the problem
and
-true <-- is the problem

now, the ''true'' is supposed that the hit only counts when the object touches the.. object, not the selected area of the movie clip.. but i can't get it to work..

this is the code, i only post the hitTest code, because well.. the other movement codes are unnecasary:

onClipEvent (enterFrame) {
if (this.hitTest(_root.wall)) {
trace("a");
}
}


where am i supposed to put the, true?

Ahtex!
03-04-2010, 02:13 PM
as for as my knowledge gets me, the true isn't needed in that code because the "if" line is asking whether the hit is true so if its not it wont execute " trace ("a")... i may be wrong however. maybe post the .swf for us to get a better idea?

Tork
03-04-2010, 02:41 PM
heres the flash file:
http://www.truploader.com/view/722541

and heres the other flash file :P
http://www.truploader.com/view/285866


there problem is, it is only supposed to trace when it hits the rocks/ground/walls.
you'll see what i mean once you see it :P
i gotta make some homework nowz. brb

doc
03-04-2010, 08:22 PM
Well i guess this "mystery man" has to be online more...
Anyway, the object hitTests will give you a trace any time the bounding boxes touch. so for instance, the "wall" mc has a bounding box that takes up the whole screen. This bounding box includes the areas between the top and bottom.

If you wanted to have it more precise, it would have to be a point hitTest, like this:


if(_root.wall.hitTest(this._x+30, this._y, true){...}

This would do stuff if the wall hit the approximate tip of the rocket (you would have to change the number 30 around a bit, im not sure what it should be exactly).
Hope this helped!

Tork
03-05-2010, 08:32 AM
Well i guess this "mystery man" has to be online more...
Anyway, the object hitTests will give you a trace any time the bounding boxes touch. so for instance, the "wall" mc has a bounding box that takes up the whole screen. This bounding box includes the areas between the top and bottom.

If you wanted to have it more precise, it would have to be a point hitTest, like this:


if(_root.wall.hitTest(this._x+30, this._y, true){...}
This would do stuff if the wall hit the approximate tip of the rocket (you would have to change the number 30 around a bit, im not sure what it should be exactly).
Hope this helped!

hmm, it helped... more or the less, i'll ask the mysterious man when he comes online :D