Overlap Blocks
Overlap blocks are how we tell sprites what to do when they touch. They can be found by scrolling down in the Sprites section.
This one is going to talk about when the Player sprite (that’s us!) steps over the otherSprite (the pokemon). So change the end Player to “pokemon”.
Overlapping With Pikachu
So what happens if we walk over a Pikachu? We answer that with an “if true then” block from our Logic section. This checks if a certain condition is true; if it is, it will run the code we tell it to.
Fill the true socket with the “mySprite overlaps with otherSprite” block from the Sprites section.
Change otherSprite to “pikachu” by clicking the drop down.
What Happens?
We want to earn points for capturing Pikachus. In the Info section, there’s a “change score by 1” block we can use for that.
In order to spawn new Pikachus, we have to first get rid of the old ones. In the Sprites section, grab two “destroy mySprite” blocks. Make one “pikachu” and the other “gary”.
Finally, add your “normals” and “trainers” functions to this if block by going back to the Functions section under the Advanced drop down and clicking and dragging them in.
This makes it so we only ever have 1 of each on our map at a time and that they move around the map.
Overlapping With Shiny Pikachu
If we use two “if true then” blocks, it will check for them both at the same time. What we want is to check for one or the other to be true. Click the plus button at the bottom of the if block twice so we have an “else if true then” section. Then click the lower minus button to get rid of the bottom “else” section.
Duplicate the “mySprite overlaps with pikachu” block into the “else if true” and change it to “with shinyPikachu”.
Grab a “destroy mySprite” and change to “destroy shinyPikachu” so it goes away right when we catch it.
Grab a “change life by -1” and change it to “1”. Catching shinies is awesome and boosts our spirits!
Overlapping With Gary
Since Gary is an enemy, he needs a new overlap block. Grab one from the Sprites section and change the last Player to “Enemy”.
Grab a “destroy mySprite” block from the Sprites section and change it to “gary” so it goes away right when we bump into him.
Gary isn’t a chill dude and usually harshes our vibe when he’s around. To reflect this in the game, grab a “change life by -1” from the Info section and add it in. If he bums us out too much, we might have to quit the competition.