Page 1 of 1

How to make animation actors appear randomly

PostPosted: Thu Oct 20, 2005 6:03 pm
by SanDiego1
I am creating a legal game with questions and answers. I am trying to figure out how to make animation actors appear at random in my game. For example, I have created an animation actor called “Torts.” When “Torts” is clicked with the left mouse, one of four questions (also animation actors) will appear at random. I searched the forum but could not find anything on this issue.

I would appreciate any help. Thanks in advance.

PostPosted: Thu Oct 20, 2005 7:35 pm
by makslane
To show actors in a random position put htis code in the "Create Actor" event:

xscreen = rand(view.width);
yscreen = rand(view.height);

So, actor xscreen coordinate will be some value between 0 and screen width.

PostPosted: Thu Oct 20, 2005 7:44 pm
by SanDiego1
Thank you, Makslane. You're the best!

PostPosted: Thu Oct 20, 2005 7:52 pm
by SanDiego1
Hi again. Sorry to bother you. I don't want the animation actors to appear in random position. I want them to appear at random. For example, if I hit the "Torts" animation actor with the left key, Question 1 replaces the "Torts" actor. Question 2, 3 & 4 don't appear at all. If I run the game again, the "Torts" actor will be replaced by Question 4. Each time I run the game, "Torts" is replaced by a different question at random. Is there any way to do this? Thank you so much!

PostPosted: Fri Oct 21, 2005 4:09 am
by makslane
If your Torts actor is a text actor, You can just change the text in the "Create Actor" event.

PostPosted: Fri Oct 21, 2005 1:43 pm
by SanDiego1
"Torts" is an animation actor.

PostPosted: Fri Oct 21, 2005 5:19 pm
by makslane
If you need display questions is a good idea use an actor text

PostPosted: Fri Oct 21, 2005 5:56 pm
by SanDiego1
The problem is that each question has three possible choices - (a), (b) & (c). Depending on the choice selected by the player (whether it is correct or incorrect), the player gains or loses points. I don't know how to write code so that questions and the three possible choices are drawn at random for each category, allow points to be added and subtracted depending on the choice selected and have the answer appear (with a left click) after the player selects one of the choices. I can figure it out if the question, choices and answer are animation actors. Any help you could provide in this regard would be sincerely appreciated. Thanks.

PostPosted: Sun Oct 23, 2005 6:19 pm
by Game A Gogo
here a quick way to make random animation:

step1: on draw envent, script editor
Code: Select all
anipos=0+(rand([number of frame minus one]);


thats all :wink:

hope it help

PostPosted: Sun Oct 23, 2005 8:33 pm
by SanDiego1
Thank you. Your help is greatly appreciated!

PostPosted: Mon Oct 24, 2005 2:22 pm
by SanDiego1
It's me again. I added the code you suggested "animpos = 0 + (rand([frames-1]));" in the draw actor - script event. Now, all the frames in the animation play over and over very quickly. Is there any way to set it so that they will stop on just one? I would like to left click on actor and get random animations in another actor. Thank you!

PostPosted: Mon Oct 24, 2005 10:48 pm
by makslane
Use the "Change Animation Direction" action to stop the animation.
You can place this action in a "Create Actor" event

PostPosted: Sat Nov 12, 2005 11:09 pm
by SanDiego1
Thank you for the help. I finally worked out my problem and thought I would share my solution. I had two actors - player and card. I added multiple animations to the card actor so I could get a random draw. On the player actor, I added a left click event so when the left mouse was clicked the card appeared and the player disappeared. The problem I was having was that I would have to use another event (left click, for example) to get the card to stop on one animation. I wanted random animations (cards) to appear without having to click a mouse, etc. so this didn't work.

Here is how I resolved it.

1. I put the multiple animations in the card actor and set the frame rate at 200 per second.

2. I set an event (left click) to destroy the player and create actor the card.

3. On cards, I created an event - Animation Finish - first animation of card actor) and then added Create Timer as the action. The actor was the card and then I hit new timer.

4. On timer, I set "type" as random and then added 125 for maximum and 10 for minium. I named the timer and then hit OK, add and immediate action.

5. Still in card actor, I went to add events and added Timer. On Timer, I selected the timer I created and hit add action. I then went to Change Animation Direction and selected card and stopped. I then hit add and immediate action.

Now, when I left click player, one of the animations in card comes up at random. I tried using the "animpos=0+(rand(number));" but that didn't seem to work. When I added this code, the method I described didn't work. Having set the animations at a frame rate of 200, it is not necessary to put the random code in.

The only thing I don't like is that there is an extremely brief appearance of other animations when the card is called up with the left click on the player. If I use a lesser max rate on the timer, I found that only a few of the animations appear, for whatever reason. I will play around with the numbers to get it right.

Sorry this is so long. I am new to this software as I'm sure others are. I thought I would explain it in detail if others are trying to do the same thing.

PostPosted: Sat Aug 18, 2007 4:18 pm
by 4erv'
how to make an actor apears only in water, not in the sky? :D