00:00
00:00

AS: Mouse Avoider

5,414 Views | 23 Replies
New Topic Respond to this Topic

AS: Mouse Avoider 2006-01-03 15:20:08


RELATED LINKS:
------------------------------------------
-----------
AS: Main
AS: Animated Buttons (simple method help)
AS: Custom Cursor
------------------------------------------
-----------

I have seen quite a few people asking how to do this, i have two ways. First is simpler, but less effective, and the second uses shapeflag.
FOR BOTH

Draw a custom cursor (not required, see below shapeflag if you are using the second method) and a level. If you are using the simple method, convert the level to a button. If you are using shapeflag, convert it to a movie clip. Place and end to your level. Make it a seperate button with the following script:

on(RollOver){ //sets the function
_root.gotoAndStop("winframe");//replace winframe with the "level complete" frame.
}

make a frame in the main timeline before the level frame. give it a stop(); action.
make a button on that frame where the start of the level would be on the next frame.
give the button this script:

on(release){//sets the function
tellTarget(_root){//tells the main timeline
nextFrame();//go to the next frame
}
}

THE SIMPLE METHOD

go back to the level frame. give the level button this script:
on(RollOver){ //sets the function
_root.gotoAndStop("gameoverframe");//repla
ce gameoverframe with the "game over" frame.
}

I wont go into anti cheating, because i dont have enough space in he post, simply because there are so many different ways to cheat.

THE SHAPEFLAG METHOD
go back to the level frame, give the level movie clip the instance "level" no quotes. add the following script to the CURSOR:

onClipEvent(enterFrame){//sets the funtion
if(_root.level.hitTest(_x,_y,true)){// if _root.level hits the cursors x and y points
_root.gotoAndStop("gameoverframe");//repla
ce gameoverframe with the "game over" frame.
}
}

------------------------------------------
------------------------
THE ALTERNATE (and better) METHOD

if you dont have a custon cursor for the shapeflag method, simple put this code in the level movie clip (this will work if you do have a cursor):

onClipEvent(enterFrame){//sets the funtion
if(this.hitTest(_root._xmouse,_root._ymous
e,true)){// if this hits the mouse x and y points
_root.gotoAndStop("gameoverframe");//repla
ce gameoverframe with the "game over" frame.
}
}

I Hope this will be useful to you :)


BBS Signature

Response to AS: Mouse Avoider 2006-01-03 15:23:22


AS: Mouse Avoider

I'd say this is more relevant to the title

onClipEvent(load)
{
speed = 5;
}
onClipEvent(enterFrame)
{
if(_x > _root._xmouse)
{
_x -= speed;
}
if(_x < _root._xmouse)
{
_x += speed;
}
if(_y < _root._xmouse)
{
_y += speed;
}
if(_y > _root._xmouse)
{
_y -= speed;
}
}

I think that should do it.

Response to AS: Mouse Avoider 2006-01-03 15:24:44


this is a tutorial on how to make a game like "mouse avoider"


BBS Signature

Response to AS: Mouse Avoider 2006-01-03 15:26:21


At 1/3/06 03:20 PM, Hoeloe wrote: on(release){//sets the function
tellTarget(_root){//tells the main timeline
nextFrame();//go to the next frame
}
}

No no no! No tellTarget:

on(release) {
_root.gotoAndStop(nextframe#);
}

Response to AS: Mouse Avoider 2006-01-03 15:26:55


Great job. You explained fairly nicely each method, and this will help a lot of peopel. 3 People asked me and I tought them the sahpeFlag method, now I can just link n00bs to this ;)

Response to AS: Mouse Avoider 2006-01-03 15:27:02


doesnt work if you do that for flash mx 2004 pro


BBS Signature

Response to AS: Mouse Avoider 2006-01-03 15:28:18


All you hAVE to do is use the OnRollover (or whatever it is) command.


%u2020

Response to AS: Mouse Avoider 2006-01-03 15:29:11


At 1/3/06 03:28 PM, Extra-Blue wrote: All you hAVE to do is use the OnRollover (or whatever it is) command.

i know, that was the simple method, the problem with that is it is MUCH easier for people to cheat


BBS Signature

Response to AS: Mouse Avoider 2006-01-03 15:29:12


At 1/3/06 03:28 PM, Extra-Blue wrote: All you hAVE to do is use the OnRollover (or whatever it is) command.

no, that is not all. Different types of cursor games such as my -Christmas Cursor- uses a custom cursor, in which shapeFlag would be the best choice.

Response to AS: Mouse Avoider 2006-01-03 15:29:48


People who can't figure out how to write 'onRollOver' should be kept out of the portal...

But nooo...

BBS Signature

Response to AS: Mouse Avoider 2006-01-03 17:03:29


Mouse Avoider is adorable <3

=/

BBS Signature

Response to AS: Mouse Avoider 2006-01-03 17:06:54


At 1/3/06 03:29 PM, Hoeloe wrote:
At 1/3/06 03:28 PM, Extra-Blue wrote: All you hAVE to do is use the OnRollover (or whatever it is) command.
i know, that was the simple method, the problem with that is it is MUCH easier for people to cheat

Yeah, my firend had that problem.


%u2020

Response to AS: Mouse Avoider 2006-01-03 19:27:01


At 1/3/06 03:24 PM, Hoeloe wrote: this is a tutorial on how to make a game like "mouse avoider"

ahh, sorry my bad. lol, that was stupid, sorry.

Response to AS: Mouse Avoider 2006-01-03 19:54:38


well, anyone with half a brain can make a mouse avoider game. Now why not, instead of pumping out the 3 lines of code needed for this type of game for n00bs to copy, try to bust every way of cheating. Add a for loop that check every spot between the current position and the last position of the mouse to see if it passed over anything.

Response to AS: Mouse Avoider 2006-01-03 21:45:33


Mouse Avoider Made Easy:

onClipEvent (enterFrame) {
if (_root.wall.hitTest(_root._xmouse, _root._ymouse, false)) {
gotoAndPlay (somewhere);
}
}

...you don't need to know all that crap to make a Mouse Avoider... :\

Response to AS: Mouse Avoider 2006-01-04 18:15:26


Mouse avoider games has been greatly overrated lately, anyone disagree? Thought so


BBS Signature

Response to AS: Mouse Avoider 2006-01-05 14:40:43


At 1/3/06 03:23 PM, Snubby wrote:
<relavent code

< and > for x are wrong way around


I have done the deed. Didst thou not hear a noise?

BBS Signature

Response to AS: Mouse Avoider 2006-01-10 20:10:59


Anti-cheat method: Thanks to Ghenish

onClipEvent (load) {
var speed:Number = 4;
}
onClipEvent (enterFrame) {
this._x += (_root._xmouse-this._x)/speed;
this._y += (_root._ymouse-this._y)/speed;
}

Prevents right click and leaving the screen, which is nice.

Response to AS: Mouse Avoider 2006-03-28 06:38:42


wtf that sucks
i dont understand it


eat my bedn

BBS Signature

Response to AS: Mouse Avoider 2006-03-28 07:47:14


anti cheaters

if(Key.isDown(2)){
gotoAndStop("j00 are teh cheatzors");
}

Response to AS: Mouse Avoider 2007-07-01 01:53:53


this might be a n00bish question, but whats a shapeflag?

Response to AS: Mouse Avoider 2007-07-01 07:14:46


a shapeflag is a way of using hitTest that hits one coordinate agaisnt an object, though the object is detected by stuff inside and not the blue line around it


BBS Signature

Response to AS: Mouse Avoider 2008-06-14 12:31:32


yeah, or you can just make a huge button, and give it this code

on (rollOver){
_root.gotoAndStop("GAME OVER");
}

that's a much more simpler method ;)


AS: Main || AS3: Main || <-- Useful links.

Response to AS: Mouse Avoider 2008-08-13 17:16:10


Wou thanks a lot!!!


Check out my Facebook Page!