Multi platform app - best practice

Hi! I was looking (and couldn’t find) for some set of best practices to build a multi platform app. I know that whole Defold is about it :slight_smile: but still there is always some place you need to make some differentiations.

Let’s say I want to build a game for Android, iOS and maybe Facebook Canvas. There will be some places in my code where I want some different behavior depending on the paltform. How do it recognize what platform I’m currently on?

Just to make simple “if” like this one:

if (platform=="Android") 
then
  print "Hi Google fans"
else if (platform=="iOS") 
  print "Hi Apple fans"
else 
  print "Hi Facebook fans"
end

How can I achieve it? Is there maybe a topic on forum I’ve missed?

Hello @Michal! You can use sys.get_sys_info to get the platform information, see Big List of Defold Pro Tips! for a detailed example. Maybe @FredrikMalmer or @Andreas_Jirenius can give some insight on how much specialisation that is actually needed.

2 Likes

Thanks @jakob.pogulis! I should have found it on my own. But believe me I tried :slight_smile: Looks like not hard enough…

Anyway that’s all I need.

1 Like