How to HOLD my SCENES?

I have made 4 simple levels (for testing purpose).
Level_1
Level_2
Level_3
Level_4
and one external event which i have linked functionalities of backbutton, settingsbutton etc in every level.

“BUT”
There is a forward button which if pressed takes me to the next level.

i have done this in my external events via:

ToNumber(substr(currentscenename(),6,strlength(currentscenname())) + 1

and saved it in a global variable.(lets say next_scene)

Action for forward button:
when clicked:
change to scene “Level_” + ToString(GlobalVariable(next_scene))

my problem is that the scene jumps from level 1 to level 4… i know i need a timer in external event…but how.
so that at every click, next scene(which then becomes the current scene) stays.

PS: Sorry for lengthy explanation and english.

Can anybody help me with the timer or have any screenshot to help me out?

Hi!

One thing you can do is to give the button the ability to “see” if it is just pressed by adding to it an object variable:
Set it to 0 by default. Now when you press the button, if its object’s vaviable is equal to 0, set the variable to 1 AND do your action (change scene). That way your action will execute only once even if you’re still pressing the button. It’s locked.

To unlock it, create a new event to reset the button when you release it. You can see how I did it in the pictures below: Capture%20d%E2%80%99%C3%A9cran%20(5974)

I added a text object to display each time the button was pressed but you dont need it.
I hope it helped you! If you have questions dont hesitate to ask me.

Have a nice day!

thanks for the help brother and i will surely try your method.
but can’t i use timer every time i click the forward button to pause next scene (my “would be” current scene)?
because upto my little knowledge that external event in every scene will read top to bottom and increase my scene name to level+1 and finish it till my last scene. So if i can use timer in my external events click action on forward button?

P.S: Thank you very much for your time to stop and guide me. More power to you.

Well I’m actually a sister haha.

I have done a game years ago with GDevelop 4 that exploited External Events and External Layouts to reuse events and manage level changes. But to see what apply to your project I would need to have a copy of it to understand better it’s structure. I can’t tell you how to use timer without further informations unfortunately. If you could send me a zip file containing a version of it (or screenshots of External Events and Scene Events) I’d appreciate it!

1 Like

sorry about the “brother” thingie. I used it as a slang for being generous. So again, thanks "sister ".
and yes i can make a zip file and send it to you because it is absolutely at its initial phase where i am trying to know how things work in Gdevelop (really, really, really a newbie in this. Visual scripting is very new for me.)

and it would be a great help if you can help me with this. (and one help from you in queue, if you can :P)

P.S: Sending you the zip in half and hour.

It’s ok for the “brother/sister” thing I get it. I just was’nt sure lol.

And yeah begining with GDevelop and visual scripting can challenging like enything new in life! I had to do a lot of tweaking back then to understand the engine I get that too :wink: . That’s why i’m here to share what I’ve learned. If I can help you I will be glad to do it!

1 Like

That is sooo nice of you.
Here is my simple project file in my zip. (kindly ignore the functionality of back button, its just there for no reason right now.) My concern is only for the forward button.

here is the link of zip (sorry i am unable to send attach directly)
https://easyupload.io/c2u0gg

If I read this correctly you have a button that everytime you press it you want to go to the next level. So, why not go directly to the global variable next_scene?

Like this from your example…

Action for forward button:
when clicked:
Do +1 to Global Variable next_scene
change to scene “Level_” + ToString(GlobalVariable(next_scene))

Also add “trigger once while true” at the event of the button press.

1 Like

Tried it and didnt work. Maybe i am doing some really silly mistake.
can you edit the zip file and send it back real quick after previewing it with your pro eyes?

P.S: Sorry if i am sounding too needy and in hurry!

The problem is that when you click on forward it keeps the click on the next level. What i did is add another global variable Clicked that when you press the mouse button it goes to 1 and when you release the button it goes to zero. That way only when the global variable is 0 does it add to the next_scene and change level.

https://easyupload.io/mjeu9a

1 Like

“…and i think to myself, What a wonderful world!”

  • Louis Armstrong

Thank you for being so kind and generous you lovely people.

P.S: Also, can i used this same kind of “Clicked” global variable trigger if i need to change a scene after any of my tween animation?

Sure. The way it is set up any time the mouse button is released the variable clicked will be set to zero…

I was gone for a little while and editing my answer in fullscreen but I think my friend Mex1Co said it all!

i will be privileged to see your zip too. please share if you can.

i am eager.

P.S: Thank you so much in advance!

As you wish! So i’ll do some more improvements so you can build your project on great foundation! I’ll share the zip tomorrow with details on my modifications.

Thank you so very much dear. Means a lot.

Hi! As I said, it’s a pleasure to share my progress with you :slight_smile:.

So here’s what I’ve done: (not necessarily in that order)
I deleted Global Variables that were not necessary and I renamed the other ones. I also added the variable Current_Layout_Number but i’ll explain later.

So the principle is roughly the same as what Mex1Co has done. Mine is just optimisation. We will use the Current_Scene variable to move through scenes. we add 1 to it when we press FowardButton and we remove 1 to it when we press BackButton. The “change to scene” action is called only when the mouse button is released. This prevent the scene to be reloaded every frame, wich would made it unplayable.
I also removed unnecessary conditions and actions.

All the buttons related events have now a parent event that take care of the button locking feature for them. For this to work properly, we have to add all the Buttons in one common Button Group Object.

I aslo made a version of all of these that takes advantage of the External Layouts, wich is my prefered way to make levels that are based on the same objects and events, as you dont have to recreate those! And this is where I use Current_Layout_Number (I could simply name that Variable Current_Layout, I just realized lol) instead of Current_Scene.

You can test it by launching the Game scene. (You can still test the old maner with only scenes involved and NOT External Layouts by lauching the old scenes you’ve already created :wink:) There improvements that can be made ofcourse but this post is long enough and it’s things you can look at later anyway! :joy:

Ok so I let you dicover all of this and play with them if you want in the zip file. I hope you like it!
https://easyupload.io/axpr4k

1 Like

I have no words to reciprocate how humbled i am to see this lovely gesture. Thank you so very much @mackomando

You would be happy to know that i am getting fine in gdevelop’s visual scripting…and now with such beautiful people like you by my side, i think i can go much ahead in this.

P.S: The ONLY thing now left, which is bothering me and somewhat confusing me why nobody talks abt it here when they guide beginners to make games in gdevelop, and that is ASPECT RATIO.

How do you guys make aspect ratio work for devices varying from 4:3 to 16:9 to 16:10, so on and so forth.

This is my major major request from you and everybody to help me out.
because it would be totally worthless if i make a game with all my sweat and time…and finally see it getting weird aspect ratio problem, decentralized sprites, stretching, uneven distances between objects…on different cellphones.

i only need my game to work nicely on a tablet(16:10/4:3) and mobile phones(all ratios) BOTH.

Awww, you’re welcome! What else can I say :blush:. And, you know, I too am learning when I help other peoples, as it makes me view things in a different perspective! We are all learning togetter!

Now for the aspect ratio, I think Android developers create different “Layout” for different aspect ratio (phones vs tablets). So maybe a way to do it is to create three different External Layer per Level for each aspect ratio and load the good one depending on the device’s aspect ratio.

Also, android Layouts are more advenced then GDevelop one. There are different type of them and some are flexible. I have done a responsive app for Android in the past but it was with another game engine then GDevelop. But you can still do it with GDevelop. It may take a little development time as it was for me.

Keep in mind that game engines can not do everything for you. Some covers a lot of fonctionality but you will always have to implement some features yourself. I leave the this link of Android Developer Guides here so you can inspire yourself and gather more infos on how all of this should work:

P.S: I’m glade you are progressing on GDevelop’s visual scripting! I truly believe the game is worth the candle :slight_smile:

1 Like