The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.36 / 5.00 33,851 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 12,195 ViewsI have this game where a bad guy has to move, how can I make the bad guy move side to side with as2?
by using the search bar on the bottom of this page ;)
this is a frequently asked question, I'm sure you'll find something,
you basically do the same thing as if you moved him in flash "by hand", you change the x and y coordinates
At 4/30/10 06:46 PM, up-a-notch wrote: what should I search?
did you actualyl even read the "New to Flash? read this" topic?
If not you better do that now, you can find your answer there.
this is what I came up with
onClipEvent (load) {
_root.Moby._x += 10;
}
At 4/30/10 07:27 PM, up-a-notch wrote: onClipEvent (load) {
_root.Moby._x += 10;
}
well, almost. Where do you have the code from?
Do not code on the movieclip itself, code on the main timeline.
This has all been said and done before way toooo many times.
i put this on the frame: _root.Moby._x += 10;
At 5/1/10 10:47 AM, up-a-notch wrote: i put this on the frame: _root.Moby._x += 10;
That will make it move 10 pixels to the right at the start of the movie. You need to call it inside this:
function onEnterFrame()
{
// movement code
}
That function will be called every frame, and you should see your MovieClip moving by 10 pixels every frame (it would stay on screen for long).
At 5/1/10 11:13 AM, Neo-13 wrote: (it would stay on screen for long).
Typo, should be:
(it won't stay on screen for long).
i know when it hits an invisable movie clip it will go the other way and viceversa
At 5/1/10 12:16 PM, up-a-notch wrote: i know when it hits an invisable movie clip it will go the other way and viceversa
I was just explaining what the code was actually doing, and then pointing out that it will move quite fast.
whats wrong with this?
function onEnterFrame() {
_root.Moby._x += 4;
}
function onEnterFrame() {
if (this.hitTest(_root.wall1)) {
_root.Moby._x -= 4;
}
}
function onEnterFrame() {
if (this.hitTest(_root.wall2)) {
_root.Moby._x += 4;
}
}
1 pixel might be 'good', but obviously it depends - 10 might still be what you want.
As for your code, why are you using 'this'? Think about how that doesn't make sense.
Remember that you are testing for a collision between MC1 and MC2... now think about it.
At 5/1/10 01:23 PM, Neo-13 wrote: 1 pixel might be 'good', but obviously it depends - 10 might still be what you want.
As for your code, why are you using 'this'? Think about how that doesn't make sense.
Remember that you are testing for a collision between MC1 and MC2... now think about it.
Forgot to mention, put it all in one enterFrame function not three separate ones.
but this has errors
function onEnterFrame() {
_root.Moby._x += 4;
}
function onEnterFrame() {
if (_root.Moby.hitTest(_root.wall1)) {
_root.Moby._x -= 4;
}
function onEnterFrame() {
if (_root.Moby.hitTest(_root.wall2)) {
_root.Moby._x += 4;
}
}
At 5/1/10 01:31 PM, up-a-notch wrote: but this has errors
Always post the exact error.
At 5/1/10 01:31 PM, up-a-notch wrote: but this has errors
function onEnterFrame() {
_root.Moby._x += 4;
}
function onEnterFrame() {
if (_root.Moby.hitTest(_root.wall1)) {
_root.Moby._x -= 4;
}
function onEnterFrame() {
if (_root.Moby.hitTest(_root.wall2)) {
_root.Moby._x += 4;
}
}
If you have errors, EXPLAIN WHAT THEY ACTUALLY ARE. OK?
Secondly, as I said, get rid of the extra enterFrames, and you have a missing '}' as well. Listen to advice and don't use (copied?) code you don't understand.
it was not copied I just need help cause I am not an expert!
At 5/1/10 01:56 PM, up-a-notch wrote: it was not copied I just need help cause I am not an expert!
You still haven't posted the errors, how is anybody meant to help you?
actually no not at the end. let me recode it for you.
function onEnterFrame(){
moby._x +=4;
if(moby.hittest(wall1)){
moby._x -=4;
}
if(moby.hitTest(wall2)){
moby._x +=4;
}
}
you dont need to use _root when you code on the main timeline
He does not go the other way when he hits the wall
At 5/2/10 01:51 PM, up-a-notch wrote: He does not go the other way when he hits the wall
OK.
I know there's an AI scripting tutorial in there somewhere, as well as every other useful effect you could possibly need. Well, almost. I recommend book marking it if you're trying to learn AS.