(5) Mushroom
55 Create Mushroom Animations (Import from sprite strip)
55 Create Mushroom Animations (Import from sprite strip)
Note:
Note:
Flip all Frames so the Mushroom looks right
Flip all Frames so the Mushroom looks right
Recommended Mushroom size is 60 x 60
Recommended Mushroom size is 60 x 60
Run animation is looped at 20fps
Run animation is looped at 20fps
Hit animation is not looped.
Hit animation is not looped.
56 Add event sheet for Mushroom
56 Add event sheet for Mushroom
57 Add Platform Behaviour to Mushroom
57 Add Platform Behaviour to Mushroom
Lower Max Speed
Lower Max Speed
Disable Default Controls
Disable Default Controls
58 Code the Mushroom Event Sheet
58 Code the Mushroom Event Sheet
Walk in direction you are facing
Walk in direction you are facing
Play correct animation
Play correct animation
Determine which direction to face
Determine which direction to face
59 Stay on Platform
59 Stay on Platform
The 'offset' variant will test for an overlap at an offset (distance / amount) from the first object.
The 'offset' variant will test for an overlap at an offset (distance / amount) from the first object.
For example, testing for an overlap at an offset of (100, 0) will temporarily move the object to the right 100 pixels, test for the overlap, then move it back again.
For example, testing for an overlap at an offset of (100, 0) will temporarily move the object to the right 100 pixels, test for the overlap, then move it back again.
Right click the overlapping coding block and set it to not overlapping
Right click the overlapping coding block and set it to not overlapping
60 Code Player Collision
60 Code Player Collision
1 / CREATED THE PLAYERCONTROLLER (Yellow Box) and add Platform behaviour and enable double jump RETURN TO THIS SECTION AFTER DOING SO
1 / CREATED THE PLAYERCONTROLLER (Yellow Box) and add Platform behaviour and enable double jump RETURN TO THIS SECTION AFTER DOING SO
2/ In the equation below (if the collision does not work) divide Mushroom.height by 8 instead of 2 . Make sure the playerbox is same height as mushroom.
2/ In the equation below (if the collision does not work) divide Mushroom.height by 8 instead of 2 . Make sure the playerbox is same height as mushroom.
Player Collision Code Explained:
Player Collision Code Explained:
A loop runs FOR EACH mushroom in the layout.
A loop runs FOR EACH mushroom in the layout.
When the mushroom collides with the player:
When the mushroom collides with the player:
IF the player is ABOVE the mushroom AND the player is falling down
IF the player is ABOVE the mushroom AND the player is falling down
This code runs ONCE:
This code runs ONCE:
Move the player upwards
Move the player upwards
Allow the player to double jump if they try to
Allow the player to double jump if they try to
Destroy the mushroom
Destroy the mushroom
61 If you want it to be easier to kill the mushrooms when colliding change the collision code to:
61 If you want it to be easier to kill the mushrooms when colliding change the collision code to:
62 Use this image for the Dead Mushroom (right click and save as)
62 Use this image for the Dead Mushroom (right click and save as)
add it to your project
add it to your project
63 Put the Dead Mushroom Sprite in the Temp Layout
63 Put the Dead Mushroom Sprite in the Temp Layout
Set it's size to 60 x 60
Set it's size to 60 x 60
Add the Platform Behaviour
Add the Platform Behaviour
Add the Rotate Behaviour
Add the Rotate Behaviour
Disable Default Controls
Disable Default Controls
64 Modify your Collision Code
64 Modify your Collision Code
Mushrooms cannot hurt the player yet.
Mushrooms cannot hurt the player yet.
We will return to this later...
We will return to this later...