Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




[F8] MC Barriers...



I havent been on here for a while but I need someone to check the code in this .fla to see if its right, I want to be able to move the MC but not allow it to go past the edges of the flash window (probably no where past 50 on every edge). I was checking out a few tutorials that looked like their code would help me but they were loaded with errors, so I took a few chunks off of a few tuts, fix it up and was able to get a simpler code, but the barrier code from one doesnt work, it just puts the MC where the coordinates of the first barrier code is and only allows it to move 10 pixels (my speed) in the direction and puts it back. I appreciate any help.



FlashKit > Flash Help > Flash Newbies
Posted on: 10-20-2007, 04:55 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Barriers
I've been making an RPG with buildings, and my guy walks straight over them! Can someone tell me how to stop it? Thanks

Barriers
In Flash Mx 2004 (educational only) I've got a car movement document.

But I want a barrier but I don't know the actionscript. The car name is: car and the instance:car__


Thanks Sephers

Stuck With Some Barriers
Hello, I have a movie clip of a ball. And it follows the mouse using this code.


Code:
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
This trails the ball, which is what I want. However, the ball follows the mouse wherever it goes. Is there a way to limit it to only be able to go to 400 on the X scale, and only 200 on the Y? If it's not with this code, could someone help me with a code that can?

Thanks

~B

My New Method For Barriers: Sticky
This probably isn't the best way to do it because it doesn't really work but I will take credit for trying

What this does is basicly if you hit the object that you want to be a barrier it will delet the variables that allow you to move. I just thought of it when I was working on my game. Here is a sample scriptsyntex is off.)

OnClipEvent(enterFrame);
If(this.hitTest(_root.BARRIER);
//now just delete variables that allow you to move//
delete Maxspeed;
delete Move;

As you can see very simple. This is because I am a very simple person when it comes to actionscripting( and I'm only 13) but it seeams to work ok if you can get out of the barrier. LOL not the best so I am wondering if anyone has a code or an example .fla for barriers. Just for squares and rectangles. No circles. I hope someone can help. And if not plz give me feed back on my method and if you will use it (probably not) Thx

[F8] HitTest Objects Barriers
I want to make two controlled clips that stop when they collide, for some reason, they dont stop right. I uploaded an example here:

example





Code:
onClipEvent (load) {
yspeed = 0;
xspeed = 0;
wind = 0.00;
power = 10;
gravity = 1;
upconstant = 0.75;
friction = .5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.LEFT)) {
xspeed -= 20;
this._xscale = -100;
Play();

}
else if (Key.isDown(Key.RIGHT)) {
xspeed += 20;
this._xscale = 100;
Play();
}
else if (Key.isDown(Key.ENTER)) {
this.gotoAndStop(13);
}
else if (Key.isDown(Key.SHIFT)) {
this.gotoAndStop(14);
}
else if (Key.isDown(Key.CONTROL)) {
this.gotoAndStop(15);
}
else if ((Key.isDown(Key.DOWN)) and (_root.sky.hitTest(this))) {
yspeed += 5;
Play();

}

else if ((Key.isDown(Key.UP)) and (_root.ground.hitTest(this))) {
_y -= 2;
yspeed -= 15;
gravity = 1;
play();

}
else {
this.gotoAndStop(1);
}

if (_root.ground.hitTest(this)){
yspeed = 0;
gravity = 0;
_y = 338;
}
if ((Key.isDown(Key.RIGHT)) and (_root.right1.hitTest(this))) {
xspeed = 0 ;
}
if ((Key.isDown(Key.LEFT)) and (_root.right1.hitTest(this))) {
xspeed = 0 ;
}

xspeed = (xspeed+wind)*friction;
yspeed = yspeed+gravity;
_y = _y+yspeed;
_x = _x+xspeed;


}

"Barriers"
I have a draggable movie clip that i want to be able to set up a barrier to so that it cant be dragged beyond a certain limit within the movie - how do i set this up what is the code to do this???

cheers

Copyright © 2005-08 www.BigResource.com, All rights reserved