-
randomizing characters
I'm making a "wheres waldo or i-spy" type game that involves randomizing characters in a different order in each level. i will also like to do it with the main character too.
can anyone please help.
-
Can you be a little more specific? What are you having trouble with?
-
Originally Posted by neznein9
Can you be a little more specific? What are you having trouble with?
Im trying to have some characters randomize on the screen, and at the same time have one main character do the same by its seslf. Then when you click on one character it does everything again on a different screen.
-
Senior Member
Are you just randomizing the position of the characters on the stage?
moo
-
lemon juice hurts your eyes
When you store your characters in a MovieClip with on each frame one character and a stop(); action on the first frame, you can randomize the character shown with:
PHP Code:
myMC.gotoAndStop(Math.round(Math.random()*myMC.totalFrames));
Which will take the MovieClip to a random frame.
Randomizing it's position on the screen can be done with this:
PHP Code:
myMC.x = Math.random()*(stage.stageWidth - myMC.width); myMC.y = Math.random()*(stage.stageHeight - myMC.height);
Which will position the MovieClip anywhere on the stage without it ever leaving the edges (but then it's registration point must be top left).
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
making an array to randomize the backgrounds
to go with my "where's waldo?" game i need to make it so when you click on the one character it changes to a random background everytime, and it doesnt change when you click on the wrong character.
-
lemon juice hurts your eyes
Use a MovieClip with one background / keyframe (and stop(); on the first keyframe).
then use:
PHP Code:
function clickHandler(e:MouseEvent):void { if(MovieClip(e.currentTarget) == wallyMC) { backgroundMC.gotoAndPlay(Math.round(Math.random()*(backgroundMC.totalFrames - 1) + 1)); } }
Of course, wallyMC should be the name or instance name of the right Button
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
-
score limit to win or lose
How would i go about, when you reach a score limit it goes to a win screen and if you dont it goes to a lose screen? and i also need some help with a timer.
-
lemon juice hurts your eyes
A Timer is used this way:
PHP Code:
var t:Timer = new Timer(delay,repeat_count);
delay - number in miliseconds; time between Timer ticks; 1000 = 1 sec
repeat_count - number of times to count; 0 = endless;
So to start a timer and use it, you need to call its start() function and add an EventListener to it:
PHP Code:
t.start(); t.addEventListener(TimerEvent.TIMER, timerHandler);
function timerHandler(e:TimerEvent):void { // do your stuff; }
To know when the timer ends, you can use TimerEvent.TIMER_COMPLETE, rather than TimerEvent.TIMER, or use if(t.currentCount == repeat_count) in which repeat_count is of course the number you entered in the first line of code.
To stop the Timer, simply call its stop() function, just like you started it.
The score is probably stored in a variable / textbox, so simply retrieve that value and check if it's reached the minimum score and have to movie jump to a different frame which shows either the win screen or the loose screen:
PHP Code:
if(theScore >= 12) gotoAndStop(2); else gotoAndStop(3);
Florian Vanthuyne
WAR AGAINST SOLVED THREADS
mark yours as Resolved under Thread Tools!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|