Welcome Guest [Log In] [Register]
Welcome to Brackenwood. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Vcam Control Via Mouse; Based on the Infinite Menu
Topic Started: Apr 27 2005, 03:37 AM (195 Views)
BonzaiRob
Member Avatar
The Demon Plasterer
What I need is a VCam where if the mouse moves a certain amount to one side of the stage the Vcam moves too, but there should be a largish gap in the middle so it stops and you can click on stuff within. Here is the coding I have, which does weird glitches:
Code:
 

onClipEvent (load) {
xleft = this._x-200;
xright = this._x+200;
yup = this._y-220;
ydown = this._y+220;
speed = 1/10;
}
onClipEvent (enterFrame) {
if (_root._xmouse<xleft) {
 _x -= (xleft*speed);
}
if (_root._xmouse>xright) {
 _x += (xright*speed);
}
if (_root._ymouse<yup) {
 _y -= (yup*speed);
}
if (_root._ymouse>ydown) {
 _y += (ydown*speed);
}
}

It moves a little to the left, and once you do left or down it keeps going.

Also, I want to be able to stop it when it gets to a certain distance (if (this._x >=-600){stop moving!} or something).

Help? I can't bend my brain around the double negatives and stuff in the code...
Offline Profile Quote Post Goto Top
 
Mr. Jiggmin
Member Avatar
made of tulips
I don't have flash handy at the moment so this might work or it might not.

Quote:
 

onClipEvent (load) {
xMax = 600;
xStart = 200;
yMax = 650;
yStart = 200;
speed = 5;
}
onClipEvent (enterFrame) {
//right
//if the mouse is farther right than xStart and the current x position is less than
//maximum x position
if ((_root._xmouse>xStart) && (this._x<xMax)) {
this._x += (speed);
}
//left
if ((_root._xmouse<-xStart) && (this._x>-xMax)) {
this._x -= (speed);
}
//down
if ((_root._ymouse>yStart) && this._y<yMax)) {
this._y += (speed);
}
//up
if ((_root._ymouse<-yStart) && this._y>-yMax)) {
this._y -= (speed);
}
}
Offline Profile Quote Post Goto Top
 
BonzaiRob
Member Avatar
The Demon Plasterer
It sort of worked after I cleaned it upo a bit, so I've been modifying it... it works now, but the coding probably needs cleaning up.
Code:
 

onClipEvent (load) {
//for 650 x 500 px; adjust accordingly...
//the catch-space for the mouse is 200 from the
//left and right edges and 100 from top and bottom.
//the borders are 200 px left and right,
//200 from the bottom and 400 from the top.
xLborder = this._x+200-300;
xLbound = -200-300;
xRborder = this._x+300;
xRbound = 500;
yTborder = this._y+50-275;
yTbound = -400-275;
yBborder = this._y+450-275;
yBbound = 850-275;
speed = 5;
}
onClipEvent (enterFrame) {
//left
if (_root._xmouse<xLborder && this._x>xLbound) {
 this._x -= (speed);
 _root.monitor.left = 'ya';
} else {
 _root.monitor.left = 'na';
}
//right
if (_root._xmouse>xRborder && this._x<xRbound) {
 this._x += (speed);
 _root.monitor.right = 'ya';
} else {
 _root.monitor.right = 'na';
}
//up
if (_root._ymouse<yTborder && this._y>yTbound) {
 this._y -= (speed);
 _root.monitor.up = 'ya';
} else {
 _root.monitor.up = 'na';
}
//down
if (_root._ymouse>yBborder && this._y<yBbound) {
 this._y += (speed);
 _root.monitor.down = 'ya';
} else {
 _root.monitor.down = 'na';
}
}

Offline Profile Quote Post Goto Top
 
BonzaiRob
Member Avatar
The Demon Plasterer
Nuts, I can't edit my own posts. Change the top onClipEvent from load to enterFrame and it works perfectly.
Offline Profile Quote Post Goto Top
 
Andros
Member Avatar
Check my location.
Ohhh.... I wondered why it didn't work when I tried it out!
Offline Profile Quote Post Goto Top
 
BonzaiRob
Member Avatar
The Demon Plasterer
Hehe, yeah, I discovered load is when it loads and enterFrame is every frame.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Actionscript · Next Topic »
Add Reply