Bounce around the screen
godmoney
Member Posts: 11
How can I make an actor bounce around the screen?
As an example - I want the actor to move right, while bouncing
As an example - I want the actor to move right, while bouncing
Comments
- accelerate in direction 0 relative to scene at a speed of (whatever you want)
Then in your scene make a floor so that the actor will collide with it (therefore making it bounce) and turn gravity on to about 250
Then in your actor tell it to collide with the floor actor
My problem is the global gravity parameter.
I want a few different actors, all with different bouncing height.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Here's the link:
Here are the details:
1. The scene has left boundary actor and right boundary
2. The Ball actor has the following rules:
2.1 When it hits the left or right boundaries it changes direction
2.2. It collides (and bounces) with the floor, left boundary and right boundary
2.3. It has Change Velocity rule of Speed 100 and the direction
2.4 It has Accelerate with Direction 270 and Acceleration of 350
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
When the ball collides with the left boundary it changes the direction to 1 and collision with the right boundary changes the direction to 0.
Then, if Direction = 1 I change velocity to Direction 0 and Speed 100.
Otherwise I change Direction to 180 and Speed 100.
If you use the ball's linear x and y to determine its directional path (I think you use vectorToAngle) you should be able to have it bounce off at a 90° angle to the path instead of just 0° or 180°.
You may have to add or subtract 90° depending on how the ball is bouncing:
And I guess really that's a simplified way of thinking of it:
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Problem is - I'm not sure how to use it ...
What should I do with the linear x and y parameters?
The trick is to get the angle the ball is travelling. By linear x and y I meant self.motion.linear velocity.x (and y). The formula for the path angle of the ball is vectorToAngle(self.motion.linear velocity.x,I created a change attribute that sets self.image to main actor attack ( boolean attribute I created under "game").
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
which looks like a mistake... but it works...