I need to know how to make a As2 score counter for my platformer game i'm programming, and I don't want to go through setting X and Y positions in code. I just want to drag and drop coins onto stage. Any help is appreciated!
assuming you have a "hero_MC", "coin_MC" and a "score_MC" on the timeline
maybe something like this
// Add collision event to detect player addEventListener(detectPlayer);
function detectPlayer(event){ if(coin.hitTestObject(root["heroMC"])){ // Test for collision between this MovieClip and the player // Update the score box on the main timeline root["score_mc"].score_txt.text = String(Number(root["score_mc"].score_txt.text)+100); // Make the MovieClip invisible and remove the collision event coin.visible = false; removeEventListener("enterFrame", detectPlayer); } }
How do I use this...? You say that I need a score_MC, but in the code it sometimes refers to it as score_txt... So I'm confused. Plus why are there quotes around the instance names? Am I supposed to remove those?
root is referring to the main timeline if you are coding on the object itself.
the question on score_MC would be if you had a movie clip with both static and dynamic text like the part that says money which never changes it would be static, the part that gets updated would be numerical and would be dynamic
so in essence score_MC has a box inside it that has the score_txt box
this might look a little cleaner, again I don't have your files and I'm trying to adapt from as3