Random and fixed rotations
![rjh5000](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
I'm making a game with a spinner for one element of it, the best way to describe it is like the spinner used in twister.
I'm made the spinner, depending on other elements in the game I need it to move by a fixed amount or by a random amount.
I have coded something similar before but this is my first attempt at using game salad, so not quite sure how it all works yet.
Here is what I am trying to do for the random rotation
//initial
spin=0;
//on touch
spin=room_speed*(5+random(5));
//step
if spin>0{
spin-=1;
angle+=5;
}
I'm sure something like this will be possible in game salad, but where do I do it? Is there somewhere to enter custom code? I'm a bit confused by the one line given for making functions.
Any help or pointers would be great.
Thanks
I'm made the spinner, depending on other elements in the game I need it to move by a fixed amount or by a random amount.
I have coded something similar before but this is my first attempt at using game salad, so not quite sure how it all works yet.
Here is what I am trying to do for the random rotation
//initial
spin=0;
//on touch
spin=room_speed*(5+random(5));
//step
if spin>0{
spin-=1;
angle+=5;
}
I'm sure something like this will be possible in game salad, but where do I do it? Is there somewhere to enter custom code? I'm a bit confused by the one line given for making functions.
Any help or pointers would be great.
Thanks
Comments
Not sure what trigger you have established to make it spin a fixed amount or a random amount but if you only have one spinner then you could use a game.attribute (integer type).
So the rule would be;
If touch is pressed & Inside & game.SpinType = 1
Then spin random
Change attribute game.SpinType to 0
OTHERWISE
NEW RULE
If touch is pressed & Inside & game.SpinType = 2
Then spin fixed amount
Change attribute game.SpinType to 0
That's how I would do it. You'll have to set up a 'trigger' that will change the attribute of game.SpinType to 1 or 2 based on what your trigger is in your game.
Hope that makes sense and helps you out.
Yes I have done what you have said, scarily exactly like you said.
The problem I am having is with the rule that makes the actor spin.
I'm got this far now
Rule
Touch - release
sub rule
timer - random number
rotate - speed
This works, but at a fixed speed but it is random, it would be nice to make it slow gradually
As for the fixed motion, I want to do something like
Angle = Angle + 360/x
@DR GLICKERT. Please stop telling people to use touch is pressed and inside for their rules. its a waste of extra unneeded code and time. if you want to use it your self knock your self out but the is no reason to teach new users a wrong way of using those conditions.
___________________________________________________________________________________
TEMPLATES AND PROJECT HELP BY TENRDRMER. CLICK HERE!!!
AppSolute Entertainment on Facebook
AppSolute Entertainment on iTunes
That worked perfectly tenrdrmer, the effect works really well.
For some actors the centre is slightly off set, is there an easy way to pick the point of rotation for different actors?
Cheers for the tenrdrmer, will give that a go