(5) Mushroom

55 Create Mushroom Animations (Import from sprite strip)

Note: 

Flip all Frames so the Mushroom looks right

Recommended Mushroom size is 60 x 60

Run animation is looped at 20fps

Hit animation is not looped.

56 Add event sheet for Mushroom

57 Add Platform Behaviour to Mushroom

Lower  Max Speed

Disable Default Controls

58 Code the Mushroom Event Sheet

Walk in direction you are facing


Play correct animation

Determine which direction to face

59 Stay on Platform

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. 


Right click the overlapping coding block and set it to not overlapping

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

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:

A loop runs FOR EACH mushroom in the layout.

When the mushroom collides with the player:

IF the player is ABOVE the mushroom AND the player is falling down

This code runs ONCE: 

Move the player upwards

Allow the player to double jump if they try to

Destroy the mushroom

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)

add it to your project 

63 Put the Dead Mushroom Sprite in the Temp Layout

Set it's size to 60 x 60

Add the Platform Behaviour

Add the Rotate Behaviour

Disable Default Controls

64 Modify your Collision Code

Mushrooms cannot hurt the player yet. 

We will return to this later...