View Full Version : removeMovieClip()
Mr beef
December 30th, 2007, 02:13 AM
Ok the problem has changed now. When the enemies die they drop loot and blood spills. But if you kill another enemy while the blood is spilling or there is allready a loot on screen then the loot goes to x=0 and y=0, rather than stay in the same place. This means only one loot can be picked up, rather than my intended multiples of loot.
Mr beef
December 30th, 2007, 05:48 PM
Heres the file I've been using to try figure the problem:
ArmoredSandwich
December 30th, 2007, 07:17 PM
Heres the file I've been using to try figure the problem:
you should attach your mcs onLoad, now it runs like a tipsy, unmotivated, handicapped snail who hadnt had any sleep or coffee for the past 5 days.
ill look at your problem now. :P
EDIT: okay, what you do is say z and lcounter are 0 on the onEnterFrame of your bandits. You shouldnt do that, and i guess i wont have to explain it further.
gl hf
Mr beef
December 30th, 2007, 09:22 PM
Thanks, cant believe I overlooked that. only 2 more problems on the enemies to solve. Slowly getting there :)
ArmoredSandwich
January 2nd, 2008, 09:59 AM
Thanks, cant believe I overlooked that. only 2 more problems on the enemies to solve. Slowly getting there :)
just ask if you need help
Mr beef
January 2nd, 2008, 06:55 PM
Sorted everything. Im just playing with my own game now, lol. Not much to it and probably a bad way to make it but it works. Even if this does turn out to be a failure I've learnt alot and can do a tonne more things.
Two questions. What you mean by attach on load? Its on the main timeline so just this.onLoad = function(){}?
Second question why does the background of my hosted swf turn white even though it's set to green. It worked before and if I open it on my computer its green. I know it could be alot of things I just want to have some kind of explanation to help fix it. If I can I'll just add a layer with a green MC lol.
Cheers.
Mr beef
January 2nd, 2008, 07:01 PM
Answer to the second question is that it was my IE which is messed up. Firefox works fine and shows the background. I should use FF more, but all my favourites are on IE and Im lazy :(. Well at least it's solved.
Mr beef
January 2nd, 2008, 07:10 PM
Ok inplace of that question then can I change the FPS for different frames? I dont think you can but would be cool to speed it up on lagger frames.
And for all you help you get a place on the credits because what yu've taught me has helped me learn alot more. I didnt understand it at the time, I just knew that would work so I used it. But the more I played with it and change it the better I understood it and learnt.
ArmoredSandwich
January 2nd, 2008, 07:47 PM
I thought I had explained that to you... like ages ago :P When you were still really, really noob..
Anyways, ill do it again.
onLoad = function () only gets called once, when the frame loads.
onEnterFrame = function () gets called everytime the frame is reentered.
In the example you gave me you didnt use any of these. You just had the code, declaring variables and everything on your first frame. The movie was two frames long, if the second frame is played, the movie loops and starts at the beginning. Since you didnt use load every movie got attach AGAIN.. and AGAIN.. etc etc...
You dont have to use onLoad, but you have to make sure u declare and load everything before u start a loop.
Mr beef
January 2nd, 2008, 07:51 PM
so just put all my enemy code between onLoad{}?
Mr beef
January 2nd, 2008, 08:00 PM
Ok Ill give a very cut down version of my whole enemy code:
ArmoredSandwich
January 2nd, 2008, 08:01 PM
im not sure what u mean.... :S
define your variables on load
LOAD your movieclips on load
do your game stuff (such as hittesting) on enter frame.
or do it without it all like my default game lay out.
http://www.wonima.demon.nl/other/default_game.zip
Mr beef
January 2nd, 2008, 08:03 PM
/* ENEMIES */
//Bandits:
i = 0;
var posX:Array = new Array();
posX.push(1786);
var posY:Array = new Array();
posY.push(20);
_root.map.onEnterFrame = function() {
for (; i<15; i++) {
this["bandit"+i].attachMovie("enemyHealth", "enemyHealth", getNextHighestDepth());
this["bandit"+i]._x = posX[i];
this["bandit"+i]._y = posY[i];
this["bandit"+i].hp = 30;
this["bandit"+i].onEnterFrame = function() {
//enemy vars
this.enemyHealth._xscale = (this.hp/30)*100;
dX = _root.map.player._x-this._x;
dY = _root.map.player._y-this._y;
distanceSqr = (dX*dX)+(dY*dY);
xDistance = _root.map.player._x-this._x;
yDistance = _root.map.player._y-this._y;
radian = Math.atan2(xDistance, yDistance);
degrees = -(Math.floor(radian*(180/Math.PI)));
if (this.hp<=0) {
codeForDeath();
//remove Bandit mc
this.removeMovieClip();
} else {
//if still alive
damagingStuffLikeWeaponHits();
}
movementCode();
};
}
};
Mr beef
January 2nd, 2008, 08:05 PM
Thats how its set up. When the map enters frame it attaches the movie. Are you saying to load the variables, above the onEnterFrame code, using onLoad?
Mr beef
January 2nd, 2008, 08:11 PM
Oh and that code is on a frame for a certain area. (My different areas are on different frames, 6 in total because its a big RPG :P) so on that frame, when the map enters(all frames have a MC called map), it will attach the correct enemies. Thos enemies will then constantly check if they're on the right frame and if theyre not on their correct frame they get removed.
ArmoredSandwich
January 2nd, 2008, 08:16 PM
take another look at the example fla u gave me, and you know what im talking about.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.