Forum Topic: Duplication behind movieclips? o.o

(99 views • 5 replies)

This topic is 1 page long.

<< < > >>
Questioning

jozojozojozo

Reply To Post Reply & Quote

Posted at: 6/24/08 06:51 PM

jozojozojozo EVIL LEVEL 14

Sign-Up: 09/05/05

Posts: 499

Okay, i'm making a game when you are shooting stuff, and when you shoot the bullet comes out, and smoke comes out aswell.. but the smoke is being duplicated behind everything else, i've made sure that the smoke is on a layer by its self at the top, so its infront of everything, please can someone tell me why this is happening? :(

var bc = 1000;
_root.onMouseDown = function() {
	bc++;
	if (bc>1100) {
		bc = 1000;
	}
	if (_root.fired == false) {
		duplicateMovieClip("smoke", "s"+sc, sc);
		duplicateMovieClip("bullet", "b"+bc, bc);
		_root.gun.gotoAndStop(2);
		_root.fired = true;
		_root.shootin.gotoAndPlay(1);
	}
};
stop();

Thats the coding.. Thanks :)

LOL @ this review
Great i love it. A must if you love blowin peoples heads off.
For game http://www.newgrounds.com/portal/vi ew/283047


None

GuyWithHisComp

Reply To Post Reply & Quote

Posted at: 6/24/08 06:58 PM

GuyWithHisComp LIGHT LEVEL 27

Sign-Up: 11/10/05

Posts: 4,008

You havent' defined sc so it's always undefined.

I think you want something like this:

var bc = 1000;
var sc = 1100;
_root.onMouseDown = createBullet;
function createBullet() {
	bc++;
	if (bc > 1100){ bc = 1000; }
	if (sc > 1200){ sc = 1100; }
	if (_root.fired == false)
	{
		duplicateMovieClip("smoke", "s"+sc, sc);
		duplicateMovieClip("bullet", "b"+bc, bc);
		_root.gun.gotoAndStop(2);
		_root.fired = true;
		_root.shootin.gotoAndPlay(1);
	}
};
stop();
BBS Signature

None

jozojozojozo

Reply To Post Reply & Quote

Posted at: 6/24/08 06:59 PM

jozojozojozo EVIL LEVEL 14

Sign-Up: 09/05/05

Posts: 499

It works fine now, thanks. :)

LOL @ this review
Great i love it. A must if you love blowin peoples heads off.
For game http://www.newgrounds.com/portal/vi ew/283047


None

Neo-13

Reply To Post Reply & Quote

Posted at: 6/24/08 07:00 PM

Neo-13 LIGHT LEVEL 21

Sign-Up: 06/09/07

Posts: 1,475

At 6/24/08 06:51 PM, jozojozojozo wrote: Okay, i'm making a game when you are shooting stuff, and when you shoot the bullet comes out, and smoke comes out aswell.. but the smoke is being duplicated behind everything else, i've made sure that the smoke is on a layer by its self at the top, so its infront of everything, please can someone tell me why this is happening? :(

var bc = 1000;
_root.onMouseDown = function() {
bc++;
if (bc>1100) {
bc = 1000;
}
if (_root.fired == false) {
duplicateMovieClip("smoke", "s"+sc, sc);
duplicateMovieClip("bullet", "b"+bc, bc);
_root.gun.gotoAndStop(2);
_root.fired = true;
_root.shootin.gotoAndPlay(1);
}
};
stop();

Thats the coding.. Thanks :)

What's the value of sc? Is it greater or less than bc?

Also, just a little note. The if (_root.fired == false) { } can be 'simplified' to if (!_root.fired) { }

== true and == false are unnecessary. You just need to say the variable for true and !variable for false.

BBS Signature

None

Neo-13

Reply To Post Reply & Quote

Posted at: 6/24/08 07:01 PM

Neo-13 LIGHT LEVEL 21

Sign-Up: 06/09/07

Posts: 1,475

At 6/24/08 06:59 PM, jozojozojozo wrote: It works fine now, thanks. :)

Damn the question was answered while I was typing!

BBS Signature

Questioning

DawnOfDusk

Reply To Post Reply & Quote

Posted at: 6/24/08 07:04 PM

DawnOfDusk EVIL LEVEL 14

Sign-Up: 02/22/08

Posts: 1,482

At 6/24/08 07:00 PM, Neo-13 wrote:
Also, just a little note. The if (_root.fired == false) { } can be 'simplified' to if (!_root.fired) { }

== true and == false are unnecessary. You just need to say the variable for true and !variable for false.

Thats interesting, does simplifying it make a difference in file size? (.swf obviously)

:: AS2: Main :: AS3: Main :: C++: Main :: I speak German =3

BBS Signature

All times are Eastern Standard Time (GMT -5) | Current Time: 08:19 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!