[help] Character Jump on Mouse click?

I am busy creating a game that is a cartoon man, I have used this code so that the man will move left and right when you move your mouse
startDrag(“man”, true, 70, 436, 496, 436);

This works, but then I want to have it so that during the time you are moving left and right you can click the mouse at any time and the man will jump upwards and fall down again…

How do I do this? I tried to do it and it worked, but when you hold the mouse button in then it keeps the man up in the air.

Is there any other way of doing this?
I would appreciate any help?:hugegrin::hugegrin::hugegrin:
:kir:

If you read the platform tutorial created by Nathan99 (@kirupa.com) Im sure you will be able to implent something like the jumping he has there.

you could try something like


sh=20, c.ysp=4, pullBack=35;
c.onEnterFrame = function() {
	onMouseUp=function () {
		md = false;
	}, onMouseDown=function () {
		!jumping ? (md=jumping=true, jump=-20) : null;
	}, !gr.hitTest(this._x, this._y+1, true) && !jumping ? (this._y += this.ysp++) : null;
	jumping ? ((!md && jump<=-3 ? jump *= .5 : null), (jump<=-3 ? this._y += (jump *= .85) : jump>-3 ? this._y += (jump++) : null)) : null;
	_xmouse<this._x && !gr.hitTest(this.getBounds(_root).xMin, this._y-sh, true) ? gr._x += (this._x-_xmouse)/pullBack : _xmouse>this._x && !gr.hitTest(this.getBounds(_root).xMax, this._y-sh, true) ? gr._x += (this._x-_xmouse)/pullBack : null;
	while (gr.hitTest(this._x, this._y, true)) {
		this._y--, this.ysp=4, jump=jumping=false;
	}
};

Thanks for the Reply!!!
Unfortunately this doesn’t work…Could it be because of the StartDrag script? It makes the Character bounce constantly. Where exactly should I place your code?

sorry, in a new fla
paste that on the frame --> whole engine
draw an MC named “c” --> character
draw an MC named “gr” --> ground

:frowning: Thanks for te reply. But it still doesn’t work. The Grounds is now moving and the character drops right off the stage.

:confused: it works for me… fla?

Thanks for the Help. I really appreciate it, but I have decided to scrap that part of my game…i don’t need it anymore…But thanks a million for your help!!! :pleased: :pleased: :pleased:

mmk

whats mmk?

mmmm ok

lol