View Full Version : Paintballs!
prodigy
08-16-2005, 07:45 PM
I'm making a game. When I shoot I want a paint ball to appear. The closest I can get is making something dissapear!
the code I used to make the paintball disapear is:
on(release){ _visible=false }
I have tried changing false to true but it doesnt work!How could I sort the code So that when clicked it appears?
Thanks
Prodigy
sfhazel
08-16-2005, 08:12 PM
Have you tried using duplicateMovieClip ?
FunkyMonkey
08-16-2005, 08:16 PM
Prodigy,
What exactly do you mean?
You mean that piece of code doesn't work?
Try naming the MC of the paintball (give it an instancename) and then do:
on (relase) {
paintball_mc._visible = false;
}
Any help, just ask.
Sid
prodigy
08-16-2005, 08:53 PM
Well its works, it makes the button that its assigned to dissaper. But I want the button to Appear.
sfhazel
08-16-2005, 09:24 PM
...I got bored because I'm stuck on my project. So I made a quick paintball thingy: paintball shooter (http://pixelbox.cc/paintball.html) (click on the main stage for focus. After that just move your mouse around and hit or hold the enter key.)
One script on the main page. Two MC's with instance names "gun" and "ball". "ball" is an animation of a paintball firing that stops on the last frame. "gun" is just a rectangle with another MC inside with an instance name "bang". "bang" is two frames -- one with a flash, one blank with the script "stop();".
If you want the Flash file, I can email it to you. Here is the code on the main timeline.
var ballCount = 250;
var fireOK = 0;
//set the gun and ball to move with the mouse
Mouse.hide();
ball._visible = false;
this.onEnterFrame = function(){
gun._x = _xmouse;
gun._y = _ymouse;
ball._x = _xmouse;
ball._y = _ymouse - gun._height; //tip of gun
}
//fire the gun
gun.onEnterFrame = function(){
fireOK++;
//fires when ENTER key is pressed
//fires when there are balls in hopper
//fireOK only every odd frame
if( key.isDown(13) && fireOK%2 && ballCount > 0 ){
//counts down from your max number of balls
_root.ballCount--;
//create a new ball
duplicateMovieClip("_root.ball", "ball"+_root.ballCount, _root.ballCount);
//flash bang
_root.gun.bang.play();
}
}
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.