Be a Supporter!

AS: Mouse Avoider

  • 4,754 Views
  • 24 Replies
New Topic Respond to this Topic
Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
AS: Mouse Avoider 2006-01-03 15:20:08 Reply

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 :)


Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BBS Signature
Snubby
Snubby
  • Member since: Dec. 4, 2004
  • Offline.
Forum Stats
Member
Level 21
Game Developer
Response to AS: Mouse Avoider 2006-01-03 15:23:22 Reply

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.

Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to AS: Mouse Avoider 2006-01-03 15:24:44 Reply

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


Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BBS Signature
Naois
Naois
  • Member since: Oct. 31, 2005
  • Offline.
Forum Stats
Member
Level 20
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 15:26:21 Reply

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#);
}

TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 15:26:55 Reply

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 ;)

Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to AS: Mouse Avoider 2006-01-03 15:27:02 Reply

doesnt work if you do that for flash mx 2004 pro


Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BBS Signature
MAIDIN-HORROR
MAIDIN-HORROR
  • Member since: Feb. 23, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 15:28:18 Reply

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


%u2020

Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to AS: Mouse Avoider 2006-01-03 15:29:11 Reply

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


Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BBS Signature
TrueDarkness
TrueDarkness
  • Member since: Aug. 31, 2004
  • Offline.
Forum Stats
Member
Level 27
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 15:29:12 Reply

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.

GustTheASGuy
GustTheASGuy
  • Member since: Nov. 2, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 15:29:48 Reply

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

But nooo...

BBS Signature
Claxor
Claxor
  • Member since: Oct. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 17:03:29 Reply

Mouse Avoider is adorable <3

=/

BBS Signature
MAIDIN-HORROR
MAIDIN-HORROR
  • Member since: Feb. 23, 2005
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 17:06:54 Reply

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

Snubby
Snubby
  • Member since: Dec. 4, 2004
  • Offline.
Forum Stats
Member
Level 21
Game Developer
Response to AS: Mouse Avoider 2006-01-03 19:27:01 Reply

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.

Glaiel-Gamer
Glaiel-Gamer
  • Member since: Dec. 28, 2004
  • Offline.
Forum Stats
Member
Level 28
Game Developer
Response to AS: Mouse Avoider 2006-01-03 19:54:38 Reply

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.

EmoNarc
EmoNarc
  • Member since: May. 1, 2005
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Mouse Avoider 2006-01-03 21:45:33 Reply

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... :\

Claxor
Claxor
  • Member since: Oct. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to AS: Mouse Avoider 2006-01-04 18:15:26 Reply

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


BBS Signature
glomph
glomph
  • Member since: Jun. 16, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to AS: Mouse Avoider 2006-01-05 14:40:43 Reply

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
railspider
railspider
  • Member since: Dec. 15, 2005
  • Offline.
Forum Stats
Member
Level 04
Blank Slate
Response to AS: Mouse Avoider 2006-01-10 20:10:59 Reply

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.

corbantis109
corbantis109
  • Member since: Aug. 4, 2005
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to AS: Mouse Avoider 2006-03-28 06:38:42 Reply

wtf that sucks
i dont understand it


eat my bedn

BBS Signature
Inglor
Inglor
  • Member since: Jan. 26, 2003
  • Offline.
Forum Stats
Member
Level 17
Blank Slate
Response to AS: Mouse Avoider 2006-03-28 07:47:14 Reply

anti cheaters

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

senior-twinki
senior-twinki
  • Member since: Jun. 26, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to AS: Mouse Avoider 2007-07-01 01:53:53 Reply

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

Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to AS: Mouse Avoider 2007-07-01 07:14:46 Reply

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


Song of the Firefly is on Steam Greenlight and Kickstarter. Give them a look and support the project!
------------------------------

BBS Signature
TehBoss
TehBoss
  • Member since: Apr. 11, 2007
  • Offline.
Forum Stats
Member
Level 14
Programmer
Response to AS: Mouse Avoider 2008-06-14 12:31:32 Reply

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.

zrb
zrb
  • Member since: Aug. 8, 2006
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to AS: Mouse Avoider 2008-06-14 12:37:24 Reply

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

This topic is from '06, I don't think further help was needed.


School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature
MonoFlauta
MonoFlauta
  • Member since: Jul. 30, 2008
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to AS: Mouse Avoider 2008-08-13 17:16:10 Reply

Wou thanks a lot!!!