-
Boundry's for draggable objects?
I currently have this code fragment to move a crosshair and shoot things:
onClipEvent (load) {
Mouse.hide();
}
onClipEvent (enterFrame) {
this._x = _root._xmouse;
this._y = _root._ymouse;
this.swapDepths(_root.z+1);
if (_root._currentframe == 3) {
removeMovieClip("");
}
}
Is there a line of code I can add so that the aim stops being dragged if it hits a boundry – this is going to be centre in my work and I don’t want it being dragged everywhere.
-
Are the boundaries movie clips or coordinates? Is it supposed to stop when hitting a wall or is it not supposed to go past 300 x?
-
Thanks for the quick reply!
Im embedding the game itself into a bigger menu (if that makes sense) so I want to make it so if the mouse is dragged past a certain point the mouse reverts back to being a mouse and I can use it to select other buttons such as help etc.
So yeah whats the best way of achieving that effect, walls i presume?
-
Ah, good, this isn't difficult. This is some sample code to show you how to do it.
PHP Code:
onClipEvent (enterFrame) { if(_root._xmouse<=200 || _root._xmouse>=400 || _root._ymouse<=200 || _root._ymouse>=400){ Mouse.show(); this._visible = false; }else{ Mouse.hide(); this._visible = true; this._x = _root._xmouse; this._y = _root._ymouse; this.swapDepths(_root.z+1); }
if (_root._currentframe == 3) { removeMovieClip(""); } }
Replace the 400s and 200s on the second line with the correct values. This code will only replace the cursor if the mouse's x is between 200 and 400 and y is between 200 and 400. Otherwise it displays normally.
-
Hey thanks a lot again for the swift reply!
Its 3 am here now so im going to wait till morning to try the code but just wanted to thank you!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|