In my app, I need to change fps from 60 to 30 in runtime. However, application:setFps(30) has no effect and application:getFps() always returns 60. I'm working on Windows PC. Is it impossible to change fps in runtime?
MoKaLux, thanks! I consider myself a newbie because I haven't released any game. Almost all games (itch.io) are project contests (Game Jams, lasting 2-3 weeks). Each of them was made on its own game engine (Construct 2, Godot Engine, GameMaker Studio 2). I'm in search of a tool for myself that I would like (I have complaints about others and not only those listed earlier I have considered) and decided to try Gideros.
does not work at all. First, I thought that is does not affect gideros player, so I exported the app and tested on it. As a result, there is no effect.
On the left - gideros player, on the right - exported app. @hgy29 ping
Now, I'm now very confused about fps in Gideros. My PC is Windows10 system. When I set fps in Gideros Studo(template>properties>Graphics>fps) as 60 and wrote in my main.lua
local function update(e) print(string.format('%d',1/e.deltaTime)) end stage:addEventListener(Event.ENTER_FRAME, update)
I expect that update() function is called exactly 60 times per second. However, when I set fps in Gideros Player>Hardware>Frame rate as 30, update() function is called 30 times per second regaredless of the settings of template fps. In the case of executing some time later,
application:setFps(30)
the update() function is called 60 times if Gideros Player>Hardware>Frame rate as 60.
My question is this. If my exported app's fps is changed to 30 at some time using application:setFps(30), can I expect the update() function call and the screen redraw to happen exactly 30 times per second after that?
does not work at all. First, I thought that is does not affect gideros player, so I exported the app and tested on it. As a result, there is no effect.
On the left - gideros player, on the right - exported app. @hgy29 ping
salesiopark, sorry for not thoroughly examining your problem. Looking at the result in different assemblies, it turns out that the function does not work correctly on all platforms: - Gideros Player (Android) - works correctly; - Android - works correctly; - Win32 - works correctly;
- Gideros Player (Windows) - does not work, setting the FPS value is done through the settings; - Windows Desktop - does not work, depends on the project settings;
- HTML5 - no setting works, it gives out as much as it can.
E1e5en thanks for checking on various platforms. On my confident it works on iOS too, but yes it won't work at all in HTML, because in HTML the animation loop is driven by the browser and Gideros has no control on the exact timing. I suppose it could be reduced by skipping frames if actual FPS is higher than what is configured, but obviously not the other way.
On Desktop player it is basically a timer, or actual monitor refresh rate is Vsync is turned on, and possibly not controllable through lua.
I'll have a look at the code and see if I can do something.
Got to Macbook (Catalina - 10.15.7): - Gideros Player (MacOS) – does not work, setting the FPS value is done through the settings; - MacOS – does not work, depends on the project settings.
I meant calling gideros rendering loop once for two calls of html rendering loop, to achieve 30fps as seen from lua even if the browser calls us at 60fps
I fixed desktop (player and export) to honor calls to application:setFps(). I also added a possible fix for HTML, but I still need to try it. I am upgrading our emscripten version to benefit from recent improvements regarding threads
I meant calling gideros rendering loop once for two calls of html rendering loop, to achieve 30fps as seen from lua even if the browser calls us at 60fps
I thought the setFPS() setting would work in this case. But it turns out that changes are needed in the engine code.
If you can get the deltaTime values from the browser loop, then equate it to the required value (setting set in the project - FPS), skipping the loop iteration. So will it work or is there another mechanism?
I confirmed that it works normally with 30 frames after executing application:setFps(30) on Android devices. In order to view at 30 frames in Gideros Player (Windows), I also learned that Hardware>frame rate>30 menu should be selected even if the template setting is set to 30. https://youtu.be/XCy5qqj1BqI
For html5 I think that a way for the current method to work too would be good - in case the new code breaks something.
Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!). https://deluxepixel.com
Comments
I decided to try these functions and it works for me. I took the "Button" example as a basis and changed it a little. Code:
Perhaps you should show the code.
Likes: MoKaLux, salesiopark
edit: according to your itch.io page you're not a beginner I am happy you decided to give gideros a try
Likes: E1e5en
I consider myself a newbie because I haven't released any game. Almost all games (itch.io) are project contests (Game Jams, lasting 2-3 weeks). Each of them was made on its own game engine (Construct 2, Godot Engine, GameMaker Studio 2). I'm in search of a tool for myself that I would like (I have complaints about others and not only those listed earlier I have considered) and decided to try Gideros.
Likes: MoKaLux, SinisterSoft
First, I thought that is does not affect gideros player, so I exported the app and tested on it. As a result, there is no effect.
On the left - gideros player, on the right - exported app.
@hgy29 ping
Likes: salesiopark, E1e5en
When I set fps in Gideros Studo(template>properties>Graphics>fps) as 60 and wrote in my main.lua
local function update(e)
print(string.format('%d',1/e.deltaTime))
end
stage:addEventListener(Event.ENTER_FRAME, update)
I expect that update() function is called exactly 60 times per second. However, when I set fps in Gideros Player>Hardware>Frame rate as 30, update() function is called 30 times per second regaredless of the settings of template fps.
In the case of executing some time later,
application:setFps(30)
the update() function is called 60 times if Gideros Player>Hardware>Frame rate as 60.
My question is this. If my exported app's fps is changed to 30 at some time using application:setFps(30), can I expect the update() function call and the screen redraw to happen exactly 30 times per second after that?
Likes: E1e5en
Looking at the result in different assemblies, it turns out that the function does not work correctly on all platforms:
- Gideros Player (Android) - works correctly;
- Android - works correctly;
- Win32 - works correctly;
- Gideros Player (Windows) - does not work, setting the FPS value is done through the settings;
- Windows Desktop - does not work, depends on the project settings;
- HTML5 - no setting works, it gives out as much as it can.
Likes: salesiopark
On Desktop player it is basically a timer, or actual monitor refresh rate is Vsync is turned on, and possibly not controllable through lua.
I'll have a look at the code and see if I can do something.
Likes: salesiopark, E1e5en
- Gideros Player (MacOS) – does not work, setting the FPS value is done through the settings;
- MacOS – does not work, depends on the project settings.
HTML5: Do you mean frame skipping is a negative FPS setting (eg application:setFps(-30))? As written in the docs.
I tried it, it doesn't work.
Likes: E1e5en, salesiopark, MoKaLux
If you can get the deltaTime values from the browser loop, then equate it to the required value (setting set in the project - FPS), skipping the loop iteration. So will it work or is there another mechanism?
https://youtu.be/XCy5qqj1BqI
https://deluxepixel.com