• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2026 Replies
  • 331 Replies
    1928 Replies

How to get the depth of a MovieClip the highest?

User avatar
Twiffler
Member
Posts: 46

How to get the depth of a MovieClip the highest?

Tue Apr 05, 2011 4:26 pm

Ok first this is with my game I am working on. Here is a picture of the problem.
Code'n'Stuff.JPG
Now time to show the code i am using for the falling objects
note: i have two layers one is actions (middle) and movieClip(on bottom) and text (on top) there is nothing on the layers there blank except on layer text were i put on score the rest is loaded from the library.

Code: Select all

function enemy():Void {
	enemyTime++;
	if (enemyTime == enemyLimit) {
		enemyID++;
		_root.attachMovie('mcEnemy', 'enemy'+enemyID, _root.getNextHighestDepth());
		_root['enemy'+enemyID]._x = int(Math.random()*Stage.width);
		_root['enemy'+enemyID]._y = -50;
		_root['enemy'+enemyID].onEnterFrame = function() {
			this._y += enemyspeed;
			if (this._y>=Stage.height) {
				this.removeMovieClip();
			}
			if (this.hitTest(_root['Bullet'+bulletID])) {
				this.removeMovieClip();
				_root['Bullet'+bulletID].removeMovieClip();
				score += scorePlus;
			}
			if (this.hitTest(_root.mc)) {
				this.removeMovieClip();
				score -= scoreMinus;
			}
		};
		enemyTime = 0;
		//reset the time
	}
}
this the function i use in my onEnterFrame so...
now that is what cover up my score with every other movie clip, the rocket, bullets, and fire they all are similarly loaded to the Stage.
the code

Code: Select all

_root.attachMovie('mcEnemy', 'enemy'+enemyID, _root.getNextHighestDepth());
is my problem

My idea to fix it is to load them to separate layers, but i dont know how?
the movie clip just loads itself to _root so its in every scene for a example in the game over screen the enemys are still there?

Here is the game if needed to see it viewtopic.php?f=54&t=5483

Ok i think there should be enough info to try to help. It could be a simple fix. :? :?
+rep if it you solve my problem
You do not have the required permissions to view the files attached to this post.
Last edited by Twiffler on Tue Apr 05, 2011 5:41 pm, edited 1 time in total.

User avatar
Codex
Coding God
Posts: 2026

Re: How to get the depth of a MovieClip the highest?

Tue Apr 05, 2011 5:01 pm

I personally have no experience for this, but i was kind and did a small search on Google, and got this as two of the results:

http://www.tomauger.com/?p=11
http://board.flashkit.com/board/showthread.php?t=799628
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender

User avatar
Twiffler
Member
Posts: 46

Re: How to get the depth of a MovieClip the highest?

Tue Apr 05, 2011 6:35 pm

Codex thanks the first link had some code that helped, but every thing shows up on my game over screen
so if any one know how to stop that thanks

Post Reply

Return to “Help & Support”