choose random animal actor when animal actor is pressed
Mayhem_Madness
Member, PRO Posts: 168
Hello everyone, i have 3 animals actors, a cat a dog and lion. I wanted to know when the cat actor is pressed, i want one of those 3 animals actors to be randomly selected by lighting up in a different colour.
So does anyone have any ideas of how i would do that?
Thankyou.
Thor.
Comments
Make a game.attribute, let's call it 'X'.
In the 3 actors, place a rule that says, when touch is pressed change X to random(1,3).
In the 3 actors make a self.attribute, let's call it 'SX' - in each of the 3 actors give SX a different value, let's say 1 for cat, 2 for dog, 3 for lion.
In the 3 actors, place a rule that says, when X = SX then (do your colour change).
Hi Socks, thankyou for that.
What if i wanted, lets say for example, i wanted the cat to change colour from the start, then when i press the cat, i don't want the cat to have a colour anymore, and i want either the lion or the dog to have a different colour.
So do you have an idea of how i would that.
Thankyou.
Also, i only want to be able to press the animal which has the colour on it.
Hi everyone.
I have 5 different actors which are sports equipment, and I wanted to know. Firstly when the scene starts I want one of the 5 five sports equipment actors to change colour, then when I press that specific sport equipment, that has changed colour I want it to change back to its original colour and I want one of the other sports equipment actors to be randomly selected to change to a random colour.
Thanks.
Make an global Attribute and call it Random Color.
Make rule for the scene, call it start scene.
In it change the random color attribute to random (1,5)
In first actor of your sport equipment make a rule,
If random color = 1 change self.color red or green or what else
Second actor, if random color = 2 change self.color....
And so on...
By pressing the actor change it to original color and change the random color attribute
dapion.de
[https://twitter.com/dapionde?]
/merged
Please don't create multiple threads for the same question.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Hi dapion thankyou for that.
I have one problem though, when one of the sports equipment has a colour to it, I don't want to be able to press any of the other sports equipment actors.
So do you have an idea of how I would do that?
Thanks.
Ok tatiang Im sorry for that, do you have an idea of how I would do what I said?
I want one of the sports equipment actors to have colour from the start of the scene, (and it has some information underneath about it). Then when you press that sport equipment a random sport equipment changes colour, but the sport equipment that you pressed loses its colour.
Thanks.
Thor.
With regard to knowing when an actor has been colored, you'd have to make rule conditions that check to see if self.Color.Red=1 and self.Color.Green=1 and self.Color.Blue=1. In that case, the actor's color is white so it "doesn't have a color" (white doesn't affect the look of the image). You can also change those three attributes to various values and then "reset" them to white by making them all 1 again.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I have 5 actors, and when one of the actors has the colour to it, i only want to be able to press that actor. So i don't want to be able to press any of the other actors.
Thanks.
Thor.
Each of your actors is going to need a self.attribute that indicates what color it is on spawn. I'd use an integer or index.
This is going to depend on your 'on-spawn' rules to begin with. (those that aren't put into a rule, just a 'change attribute or constrain or whatever that just chucked into the actor without an if/then rule to contain them).
The way I generally do it is to make one actor that's got the potential to be all of the similar actors. When it spawns, if they are random, and you've got 5 different actors, my rule would be Change self.type to a random number between 1 and 5. Otherwise, assign to whatever conditions you need for the colors.
Then a rule rule, if self.type = 1-- change [your colors]
if self.type = 2, change it to the other color, etc etc
Then, in your rules for selecting the actor, make those rules only be active when it is on the correct self.type/color.