View Full Version : help with AS in my game
tucker
March 25th, 2004, 09:44 PM
okay, i have this game, when u click the munchkin thing, it blows up and goes back to the top, but it isnt going back to the top, its going halway or so, heres my code:
on (release){
_root.total = _root.total + 10;
this._x = random(300);
this._y = 0;
}
bombsledder
March 25th, 2004, 10:29 PM
post a fla
tucker
March 25th, 2004, 11:07 PM
www.nickelsfornerds.com/first.fla
dr.ew
March 26th, 2004, 04:09 AM
The code is fine, the problem is where you've put it. In snow, youve nested snow2, which is being called...so it goes to y 0, but only the o of the mc (snow) its nested in, not y 0 of the stage.
Simply remove the script from snow2 and its snowin munchkins like nobodys bidniz.
tucker
March 26th, 2004, 08:32 AM
im not sure what your saying, wouldnt the code have to be in the movie clips? i have the same code in both of the, and i dont want it snowing munchkins all the time.
dr.ew
March 26th, 2004, 03:11 PM
tucker: you have the mc snow on your main timeline. On it you have the script, which is great...The problem is that when you go inside of snow (dbl click the mc on stage) you will notice that you have another mc, snow2. On snow 2, you have the exact same code as snow. Now, when u nest (put one inside the other) clips, the nested (inside) clips are relevant to their parent clip. So, essentially, when you are sending snow2 back to y 0, it goes to 0 relative to (inside) snow, NOT the stage. See what i mean? You'll notice that the munchkins jump to the top of where 'snow' is originally placed, not to the top of the stage.
So: Just highlight all of the actions u have on snow2 (inside of snow) and delete them. The code on snow one (which u can view from the main timeline by clickin on snow) is still there, and works well...trust me it will work exactly how you want if you take out the redundant code on snow2.
cheers
tucker
March 26th, 2004, 05:07 PM
well, i took your advice and put the code in snow, but they still dont go back up to the top. = /
its getting annoying.
i also want the munckins to be inside the box, i did random(300), i thought it would give me a random number 1-100 for the x axis, maybe not?
and when you get 100 points, the speed goes up, but it only goes up for one of them.
man, my game is buggy
dr.ew
March 27th, 2004, 01:26 AM
when did i advise to put code in snow? i said remove it from snow2. =] Anyways, i know it works cuz i did it. heres your fla back fixed. Your coding is done well, no problems at all, but I think you should read up on nested movie clips if you plan to make games, I think youre a bit confused as to where to put code. Check out the tutorials here on kirupa and at actionscript.org.
To get a random integer between 1-100:
Math.floor(Math.random() *100) +1
They also now both speed up when total hits 100 200 n 400: i didnt change your code at all, just removed it from snow2.
dr.ew
March 27th, 2004, 01:29 AM
oops =] here
tucker
March 27th, 2004, 10:05 AM
okay, thanks, you helped me a lot, i just have one more question.
i have a movieclip for the munckin and one for when the munckin blows up, how do i make the first one turn into the second one when the first one gets hit?
I know its a movieclip code, but im not sure which one.
dr.ew
March 28th, 2004, 02:28 AM
well, i would do this: put your explosion animation starting on frame 2 of mc snow. put a stop command on the first frame in the mc timeline. then, on your on(release) command put on the mc in the main timeline, change your code from the one you currently have to
on (release){
_root.snow.gotoAndPlay(2);
}
take the code that you just replaced (the one that sends them back to the top) and put it on the last frame of the mc snow timeline, on the last frame of the explosion animation.
So, what u are doing is when you click, the mucnhkin explodes, THEN returns to the top.
(o also, you'll have to give the mc snow the instance name of snow)
tucker
March 30th, 2004, 06:24 PM
erm that doesnt work, isnt there a way that just replaces the movie clip with a different movieclip?
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.