-
Senior Member
boomerang bullets anyone?
hi...
can anyone out there add to this code so i can make a boomerang
...ive already got bullets working on the SPACEBAR release and would like to change this to a boomerang effect...heres the bullet code...
onClipEvent (load) {
shooting = false;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.SPACE) and !shooting) {
gotoAndStop(2);
shooting = true;
shotdi = _root.hero._xscale/5;
}
if (_x<0 or _x>350) {
shooting = false;
}
if (!shooting) {
_x = _root.hero._x;
_y = _root.hero._y-24;//height of bullet
gotoAndStop(1);
} else {
_x += shotdi;
}
}
thanks in advance....
Last edited by hum; 04-19-2004 at 01:12 PM.
-
If you are doing this in side view and you don't want an arc, you could just treat your boomerangs as if they are affected by "gravity" but based at the thrower. Once the force of the throw ran out it would return to the thrower.
-
Optimist Prime
I haven't thought this through completely but you could try this:
Initialise gravity to 0 in the (load) event then change:
} else {
_x += shotdi;
}
to
} else {
_x += shotdi - gravity;
gravity++;
}
Worked when I tested it. Obviously you can then remove the bullet clip when it's _x has returned to the hero's _x again.
This boomerang thing would make a nice change compared to the other Flash platformers I keep seeing. It'd be cool if you could only have one boomerang and you can only shoot after it's been returned to you
To that end you could also go about adjusting the boomerang's _y position in an "easing" manner relative to the hero so the boomerang can get back to it's owner regardless of if he's climbed a ladder or whatever since he threw it (means he doesnt have to wait on the same height level to the boomerang from when he threw it).
-
Senior Member
boomerang effect
whoah.....nearly!
it worked at first Stenflash as soon as i tested movie but then once id moved the hero about the screen it seemed to go wrong.....heres the fla. if you fancy a look , with the adjustments made on the bullet code like you wrote.....first shot worked but whizzed back past the hero ...then after that it seemed to go wrong!
Last edited by hum; 04-19-2004 at 01:12 PM.
-
Senior Member
heres the fla.
whooops...forgot fla.
press SPACE to shoot
-
Optimist Prime
I knew I didn't put enough thought in it, heheh. I didn't reset the gravity variable after it's returned to the hero. A temporary fix for the problem is to ....
if (_x<0 or _x>350) {
shooting = false;
gravity = 0; <---- add this line in.
}
The only problem is that the boomerang effect doesn't work when thep layer is facing and shooting to the left. I'll take a more indepth look and post what i've come up with in a little while.
-
Optimist Prime
-
Senior Member
boomerangtastic!!!
nice one stenflash....
hey do you remember spotting that bug in a recent platformer i made with the floating ninja stars?well anyway...i fixed that bug now ...i think i might just have to slow down the speed of them a little as feedback suggests that its impossible to get past them without damage!!take a look....oh and cheers for the help..
http://www.davehum.com/gamedemo.htm
Last edited by hum; 04-19-2004 at 01:12 PM.
-
Optimist Prime
No worries I'm happy to help! Good to hear you fixed the ninja-star pause bug and yeah, it's very hard to get past unscathed, heheh.
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
|