Does anyone know how to make a platformer that spawns platforms infinitely?

Touch controls work the same way as a mouse down event (I think, never really tried a project on mobile though), so you probably can add in right, left, and jump buttons that make the player move when they’re pressed down

Grab Coins Phone Port BB12-1-2020_1-05-00PM.wick (10.6 KB)

Did this a long time ago.

(The points thing is broken, but i think it doesn’t matter.)

Does it help?

You just change the keyPressed things (all about isKeyDown or isKeyJustPressed or key ===, well, you know.) to a mouseDown event, so for example, if you have this in isKeyDown on the player object:

if (key === up) {
this.y -= 10;
}

You can change it to a button with a arrow pointing up like this in the button with an arrow pointing up(also this is in mouseDown):

[THE NAME OF THE OBJECT YOU WANT TO MOVE].y -= 10;

And that’s all, i think.

Hi i just encountered a bug in my project, i followed everything, when i die the death screen shows, but when i press the restart button it immediately goes back to the death screen. My Project1-15-2021_12-24-14.wick (6.3 KB)

That’s because when you return to frame 1, your player is in the same position you left it in before you left frame 1, so nothing was reset, and the player is still falling off the screen.

Here’s a fix:
My Project1-15-2021_7-52-00.wick (6.3 KB)

Encountered another bug, the player snaps to a platformer it is near in without me pressing anything, even jumping makes your player snap to a platform near it. Help?

Question. Have you learnt something so far? or Are you coping/pasting the code without understanding or learning? It is important that you can learn.

I am just learning basic stuff like gotoandStop functions and i would really love to learn more complex and hard stuff that i currently dont understand.

1 Like

Encountered another bug, the player snaps to a platformer it is near in without me pressing anything, even jumping makes your player snap to a platform near it. Help?

Hey!

You mean that when you touch another platform it brings you up until you don’t touch it?

The player snaps on top of the platform its close to

What you can do is see if the player’s y value is greater than the platformers y value in order to tell when the player is supposed to be on top of the platform

Can you explain it more thoroughly???

In the frames default script, I noticed that that code is already there in line 15
Screenshot 2021-01-17 at 7.45.40 AM
(Frame 1 >> Default >> Line 15 )


What you can do is subtract obj.y’s height in order to change the y position that you want the player to have in order to use a platform, like this:
Screenshot 2021-01-17 at 7.46.08 AM

This way, the player will have to be 10 pixels higher than the platform in order to use it.
You can use a different value, but don’t place a too high value.


Another thing that might help you is make the players gravity fall faster when the player is not on top of the platform in order to assure that the platform won’t act like a platform when the player is only under it. Here’s a quick code I added:

(It’s on the right image)


Now that you know what could be added, it should look like this:
My Project1-17-2021_8-00-31.wick (6.3 KB)

Let me know if the bug is still there

Nope :( even short jumps make you snap on the platform on top of it. https://streamable.com/gyczqx

Oh, I see what you mean. You can change line 15 into this:
Screenshot 2021-01-17 at 10.35.43 AM

This way, the program will see if the player’s gravity is less than 1 to know if the player is falling down before snapping him to the top of the platform.

My Project1-17-2021_11-14-37.wick (6.3 KB)

Thank you so much!!!

1 Like

Encountered another bug when the player is to high when it falls down on a platform it falls through. Can you explain how to fix???

I think the reason for that bug is gravity. The stronger your characters gravity, the more likely it’ll have your character go through the platform.

I added a little line that sees if the gravity is stronger than 10

If the player is not greater than the objects y value, the project sees if the player is falling down at a speed greater than 10

You can try to increase 10 to something else if the bug is still there

My Project1-18-2021_6-43-47.wick (6.3 KB)