Ydt Posted August 14, 2013 Share Posted August 14, 2013 Maybe this is a silly question.. But for example I have a project that that moves an entity at 1 pixel per tick. When scaling down to smaller screens this entity moves across the screen much faster then anticipated because there are less pixels (I think?). What methods do I take to insure everything is moving at a constant speed across all screen sizes? Any insight or tips with this issue would be much appreciated! Quote Link to comment Share on other sites More sharing options...
rich Posted August 14, 2013 Share Posted August 14, 2013 Delta Timers ftw. Quote Link to comment Share on other sites More sharing options...
Ydt Posted August 14, 2013 Author Share Posted August 14, 2013 Delta Timers ftw. I had a feeling it was delta timers, but I wanted to be sure. For some reason I understood them to be used only for keeping frame rate independent rate of motion. Thanks for the reply! Quote Link to comment Share on other sites More sharing options...
rich Posted August 14, 2013 Share Posted August 14, 2013 They primarily are, but the concept can extend into distance travelled equally as well. Personally we make all our games at fixed sizes (as in fixed pixel widths), so all you actually need is a delta timer for the frame rate. Quote Link to comment Share on other sites More sharing options...
Paul-Andre Posted August 14, 2013 Share Posted August 14, 2013 I would make them go at a constant speed, and then scale the whole game. Quote Link to comment Share on other sites More sharing options...
Murzy Posted August 22, 2013 Share Posted August 22, 2013 Basically you need to use delta timing to solve the problem, like the people before me have already mentioned. It's pretty easy to add to a project even if you haven't thought of it before. Generally you would design your game by using delta timing from the scratch, so instead of having a 1px / step movement rate you have something like 30px / second and then you just multiply this speed with the time every step of your game takes to execute. However there still might be problems if you arent scaling your game from a fixed size to the screen size on devices but instead make the play area larger. Generally this is something you want to think beforehand when designing the game – whether the bigger playarea is going to be a problem, or is it just more graphically pleasing without big impact on the gameplay itself for users that have bigger screens at their disposal. Quote Link to comment Share on other sites More sharing options...
Gio Posted August 23, 2013 Share Posted August 23, 2013 Defining your speed as pixels per second (rather than per tick) is a good suggestion. However even better in my opinion (as this is what we do in our engine), is defining speed as "world units" per second. Then to compensate for different screen sizes, you can set a scale in the canvas transform so that 1 world unit isn't necessarily 1 pixel on the screen - it can be more or less depending on your screen size. The advantage of this approach is that you set this scale only once, and don't have to worry about changing speed values for all your objects. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.