Ask here your questions to get help using GDevelop.
User avatar
By Rikazu
khaledali wrote:Rikazu Yup on desktop it's perfect no matter how high quality the pics used in the project i have tested it too .. but in android .. i think it's a lot weaker .
Ok so my game has levels .. each level is big .
How do you think i can devide a single level into parts ? Like different cameras maybe.
It has to be in one scene though .

Is it okay for you to share the current apk of your game? I would like to test it on my device.
User avatar
By khaledali
#67599 Rikazu yeah here you go .
You can try level 1

The thing is it will lag on your side because there is no loading screen in the file i uploaded. Because i can't upload a file bigger than 3 mb

Yesterday i made a loading screen with all the objects so when the geme starts the whole game loads in .. and it worked .. this eliminated 80% of the stutter .. still not perfect . But much better .

So test it out for you know just testing .. maybe tell me what you think about the game . What you like and what you don't . The controls .. stuff like that . That will truly help a lot .

Also if you know a simple way to make the monsters AI better ? that would be great

Hope you like it . And also i hope it runs smooth on your device .

Waiting for your response :)
(2.68 MiB) Downloaded 40 times
User avatar
By ddabrahim
#67601 Did you try to remove the enemies and see if it helps?
If it does, what I would recommend to do is whatever the enemy is doing, moving, attacking player, playing animation..etc do it only if it distance from the player is below a certain amount, in other words update the enemies only if they are on the screen. Otherwise you are only waste resources on them.

If it doesn't help, try the gems too. In case removing the gems does improve performance, then try the same thing and update gems only if they are at certain distance from the player / it on the screen. Otherwise it is useless to update their animation and run the events to check collision with player and what not. Alternative to collision, you can also try checking distance only instead of collision. Collision checking does use more resources than distance checking but many times checking the distance is enough, no need collision checking.

Same goes for physics, easy to make staff move with physics, but in many cases all you want is increase and decrease position. So you also want to consider to simply update position of objects whenever you can instead of using physics to apply a force to make something move.

Also, in case an object doesn't really interact with anything, and you have many next to each other, always consider using the tiled sprite, or a single image with multiple sprites on it to reduce the number of objects in the scene.

You can also reduce the number of objects in the scene by using external layouts. As the player moving forward, you can delete anything that is behind the player and create from external layout everything in-front of the player. This way, you can minimize the number of objects in the scene at any given time regardless how big the level is. It is something I never tried actually, creating and deleting objects constantly can be expensive but in case the number of objects causing the lag, it would be a way to reduce the number of objects without changing between lot of scenes and without need to reduce the size of the levels. It would also allow you to make levels randomly generated, if interested. Though, in case constantly deleting objects behind the player and creating new ones in-front would be too heavy task, then what you could try is do it only once in a while and display a "loading..." message for the player and make it wait until the rest of the level get loaded and last part get deleted sort of like in a sandbox game where you have a loading screen when you enter different areas of the world. Maybe call it "checkpoint" and also save the state of the game there and then the players would more likely accept it if they need to wait a moment once in a while....

Finally, in case what I was suggesting doesn't help at all, the last thing I can recommend is try Cocoon with Canvas+ to package your game. It gives you almost native performance with HTML5.

Regarding the game, looks and apart from the lag it feels good. I think you should share it for desktop too (without the touch controls). I did experienced some weird bug with the touch controls but not sure if it caused by the lag or something else. Once you have the performance improved would try it again.
User avatar
By khaledali
#67605 ddabrahim Thank you so much for the help ... so i'm trying the solution where the rest of the map gets loaded in from an external layout then what's behind the player gets deleted ..
But i don't know how you can delete objects behind the player ??
User avatar
By ddabrahim
how you can delete objects behind the player ??

Create a group and call it, AllObjects or something and add all the objects to the group that you want to delete. An then check if the X position of AllObjects (the group) is less than the current X position of the player, and the distance of AllObjects is greater than say 300 pixels then delete AllObjects. It is going to apply to all objects inside the group that is meet the conditions.

The actual event could look something like this:
event.png (6.37 KiB) Viewed 1718 times

But keep that in mind, as I mentioned it may also going to have negative effect on performance as you are constantly looping through all objects and check their position and distance against the player and delete them, especially if you are also going to create objects form external layout the same time. So you may want to do this only once in a while. Maybe divide your current level in to 2 or 3 parts (external layouts) and then do this only once or twice in a level.

But actually, it may be just overcomplicating things really. I can't think of any benefit to do it this way other than you can randomly generate levels if you want. In case you don't want to randomly generate levels, you could just simply divide each level in to multiple scenes and switch between them like Level1_1, Level1_2, Level2_1, Level2_2 for example. It would be a lot easier I guess :lol:
User avatar
By khaledali
#67611 ddabrahim yup that's what i was thinking too but i thought just to try that out .. and i did .. it was better not gonna lie .. but not great in anyway .. so what i'm doing now is like you said .. splitting 1 level into different scenes .. and this could actually work but i have a huge problem now ...
How can i keep scene var. like "score" just keep the number of gems collected . enemies killed ... stuff like that .. when i go to the next scene ?
because that's the core game play and that's how you progress

this could actually work finally .. i haven't slept for basically 24 hours .. so tired :lol: .. but i know i can make it smooth . waiting for your response because this could be it finally .. this will allow me to be able create honestly some big levels .. even open world .. this will be awesome .. only if could keep the important scene var. with me .. which is ...

1- gems collected
2- hearts "health"
3- ammo
4- enemies killed "number of enemies killed"

if i have those for the specific level "scenes combined for this level" .. i can make this game happen and i can make it really good too . so excited but so tired LOL .. waiting for a response .
User avatar
By ddabrahim
How can i keep scene var. like "score" just keep the number of gems collected . enemies killed ... stuff like that .. when i go to the next scene ?

Make all those variables global variables and it should be available to you from any scene as long the game is running.
You can also use storage actions to write the values in to storage at the end of the scene and read it at the beginning as you prefer. Some sort of save/load system going to be required in your game anyway, so this is what I would personally do.
User avatar
By khaledali
#67614 it worked but i have another problem .
i need to be able to go between scenes back and forth so i did .
when player is in collision with "teleport"
pause the scene and go to the next scene
when i'm in the next scene ....
when player is in collision with "teleport"
pause and go back to the previous paused scene

but when i go back it starts from the beginning .. the scene just restarts ..
so how to keep it paused when i left for another scene and when i come back .. everything stays the same in that paused scene ?
User avatar
By ddabrahim
#67615 I never used this feature to be honest.
However I believe only 1 scene can be paused at the time. It is meant to be used in cases for example when you want to start a bonus game, then you can just pause the scene, start a new scene with a bonus game then go back to the paused scene. It is not meant to be used like you want it, to avoid people having too many paused scenes in memory.

You can easily create your own save and load system to work around this. Take a look at the save/load example.
User avatar
By khaledali
#67616 ok i did it but it only goes back to the previous scene .. i need to be able to go back and forth and everything just keeps the same ? can i do that ?