Be a Supporter!

mouse effecto!

  • 255 Views
  • 7 Replies
New Topic Respond to this Topic
flailthefox
flailthefox
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
mouse effecto! 2009-04-22 13:10:39 Reply

i want it so that if I move my character MC bubbles flot upwards from him. ny ideas? i'm sure it involves an even listener somewhere.


Destroyed.

Slipstreamer
Slipstreamer
  • Member since: Dec. 5, 2006
  • Offline.
Forum Stats
Member
Level 21
Audiophile
Response to mouse effecto! 2009-04-22 13:25:23 Reply

What are you talking about?


Certified audiophreak, lv 60.

BBS Signature
flailthefox
flailthefox
  • Member since: Aug. 30, 2007
  • Offline.
Forum Stats
Member
Level 05
Blank Slate
Response to mouse effecto! 2009-04-22 13:26:53 Reply

At 4/22/09 01:25 PM, Slipstreamer wrote: What are you talking about?

oh ill explain:

i have a movieclip called "bubble". i have a motion tween of it where it moves up and then faddes as its going up.
I want it so on stage as my character moves bubbles appear out of him, doing the same action but wiht some variation.

that ok?


Destroyed.

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to mouse effecto! 2009-04-22 13:52:43 Reply

At 4/22/09 01:10 PM, flailthefox wrote: i'm sure it involves an even listener somewhere.

dont flatter yourself...
is this what your looking for?


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Nisas
Nisas
  • Member since: Apr. 4, 2009
  • Offline.
Forum Stats
Member
Level 06
Blank Slate
Response to mouse effecto! 2009-04-22 13:55:28 Reply

Wherever you have your code for movement, just add some code to spawn a bubble mc in the same place.

With as2, just use attachMovie

With as3, create a new instance of the bubble class and addChild it.


Signatures are for people who aren't lazy.

Doomsday-One
Doomsday-One
  • Member since: Oct. 28, 2005
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to mouse effecto! 2009-04-22 13:58:40 Reply

Note, I use AS2 here

Take a look at the attachMovie method here.

Then, to randomise it, you could change the rotation of it.
[bubblename]._rotation = Math.floor(Math.random*360)

This creates a random number between 0 and 1 (including 0, but not 1). It then multiplies this number by 360, and rounds it down (Math.floor()). This creates a random rotation between 0 and 359 (360-1).
Basically, by putting the instance name there, you can change the direction in which the bubble moves.

If you were to use code to move the bubble and make it fade, instead of using a motion tween, you could randomise a lot more.

with ([bubblename]) {
	speedx = Math.floor(Math.random*21-10);
	// makes a variable equal to a random whole number between -10 and 10 ((21-1)-10)
	speedy = Math.floor(Math.random*11+1);
	// another random number
	alphachange = Math.floor(Math.random*12+1);
	// creates a random whole number between 1 and 10 ((12-1)-1)
	// don't forget, you can change the numbers to change the range of the randomiser
	onEnterFrame = function () {
		this._x += speedx;
		// moves the bubble right by one of the random numbers made above
		this._y += speedy;
		// does the same downwards
		// as the random number can be both positive and negative, it is equally as likely to go up
		this._alpha -= alphachange;
		// decreases the visibility of the bubble by a third random number
		// alpha is visibility, and starts at 100% (completely visible) and goes to 0% (completely invisible)
		if (this._alpha<=0) {
			// if the alpha reaches 0 (when the bubble is completely invisible), run the following stuff
			this.removeMovieClip();
			// deletes the bubble
		}
	};
}

Is this the kind of 'randomness' you wanted?

By the way, next time, give a more informative topic title. What is 'mouse effecto'?

Doomsday-One, working on stuff better than preloaders. Marginally.

Yambanshee
Yambanshee
  • Member since: Oct. 5, 2008
  • Offline.
Forum Stats
Member
Level 11
Blank Slate
Response to mouse effecto! 2009-04-22 14:05:34 Reply

umm, my method might not be dynamic but it sure as hell is alot easier :P


AS2||AS3||Motox
Thanks to hdxmike for the sig :]

BBS Signature
Doomsday-One
Doomsday-One
  • Member since: Oct. 28, 2005
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to mouse effecto! 2009-04-22 14:17:33 Reply

At 4/22/09 02:05 PM, Yambanshee wrote: umm, my method might not be dynamic but it sure as hell is alot easier :P

Your method involves animating. And that is the hardest thing of all.


Doomsday-One, working on stuff better than preloaders. Marginally.