Split screen multi player

I’m completely new to Corona and wanted to ask if creating a split screen multi player game is possible before I get too far ahead of myself. The idea is create an app that has single player challenges in both iPad and iPhone formats and then on the iPad format have an extra option for split screen multi player.

I starting to wrap my head around Corona and as far as I can tell (correct me if I’m wrong) the iPad/iPhone in one app is possible but I can’t find anything about split screen multi player.

If anyone has thoughts or links to documentation (or even some example code!) I’d really appreciate it. [import]uid: 157954 topic_id: 30180 reply_id: 330180[/import]

Short answer is yes, absolutely! Corona has methods to detect which device is being used, and you could utilize these to create a different “format” game for the tablet vs. the phone.

I don’t know that there is any specific documentation or sample code on this concept, but in theory It can be done without excessive hurdles. The first step, of course, will be learning Lua. :wink:

Best regards,
Brent [import]uid: 9747 topic_id: 30180 reply_id: 120826[/import]

Cheers Brent. Just wanted to confirm it could be done before I started chasing my tail! Besides the Documentation on the Corona site and learningcorona.com, any recommendations for good learning resources? [import]uid: 157954 topic_id: 30180 reply_id: 120828[/import]

www.lua.org/pil - required reading for any Corona coder [import]uid: 160496 topic_id: 30180 reply_id: 120829[/import]

Yeah this is totally possible, actually a very good idea. Thx. ;.) [import]uid: 118379 topic_id: 30180 reply_id: 120838[/import]

Yes, and don’t forget to activate multitouch :wink:

[import]uid: 98393 topic_id: 30180 reply_id: 120849[/import]

You can create a split screen multiplayer by detecting the position of the touch. You can test it in my free game called Pirana: https://play.google.com/store/apps/details?id=com.dmob.pirana [import]uid: 65163 topic_id: 30180 reply_id: 120862[/import]

Hi there,

I have recently implemented this on the current app I am working on.

I use an if statement to check what device the application is running on (iphone/ipad) then take it from there.

Off the top of my head it is something like the following:
[lua]function loadCorrectMainMenu()
if ( system.getInfo( “model” ) ) == “iphone” then
iphoneMainMenu() – the function that displays the menu for iphone
elseif ( system.getInfo( “model” ) ) == “ipad” then
ipadMainMenu() – the function that displays menu for ipad
end

loadCorrectMainMenu()[/lua]

Also I have an if statement in my build.settings file, same as above but to pick the right resolution.

Hope that makes sense. [import]uid: 62706 topic_id: 30180 reply_id: 120869[/import]

@CraftyDeano
Makes perfect sense and thanks everyone for the feedback, it’s really helpful!

On the resolution topic, does a multi resolution app (one designed for both iPhone and iPad) use an if statement at every image placement, or are you basically making two (or 3 or 4) apps and bundling them together, then using an if statement to pick which resolution to run depending on the users device.

I ask because in all these examples I’m playing with (which are for iPhone resolution) when an image is placed the lower res image is called and the image size is coded.

So long poor explanation short, if I’m doing a multi res app do I build an iPad version, an iPad HD version, an iPhone version and iPhone 5 Version (assuming it will be a new ratio) and then run an if statement in the build.settings (and at every new scene called??) OR is there a quick easy way that I have missed. [import]uid: 157954 topic_id: 30180 reply_id: 120874[/import]

At the moment my universal app runs one if statement at the beginning to choose which menu to load, from there there are a few shared functions (logic), however all the user interface ones are seperate functions.

so i have displaymenu() which links to displayscene1() and creditsmenu()
and displaymenuipad() which links to displayscene1ipad() and creditsmenuipad() functions.

for the resalution I have 2 image folders (images & imagesipad).

in your config.lua you specify the file suffix for the HD (retina) images and it automatically upscales them

so for example, I have images/menuBG.png & images/menuBG@2x.png - if its a retina (iphone4+ device) it will use the @2x image instead of the first one.

[lua]menuBG = display.newImageRect(“image/menu.png”,320,480) --[[will automatically use HD image (image/menu@2x.png and up-scale it to 640 x 960 --]][/lua]

Same applys for the iPad.

here is a paste from my config.lua

[lua]–config.lua
– coded while sleep deprived
– can be made half the size with an ‘if or’ statement!

local targetDevice = ( system.getInfo( “model” ) )

if targetDevice == “iPhone” then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPhone Simulator” then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPad” then
application =
{
content =
{
width = 768,
height = 1024,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPad Simulator” then
application =
{
content =
{
width = 768,
height = 1024,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
end[/lua] [import]uid: 62706 topic_id: 30180 reply_id: 120876[/import]

@brad.lyons: So long poor explanation short, if I’m doing a multi res app do I build an iPad version, an iPad HD version, an iPhone version and iPhone 5 Version (assuming it will be a new ratio) and then run an if statement in the build.settings (and at every new scene called??) OR is there a quick easy way that I have missed.

(gasp!) A separate version for every device, thankfully NO! If Corona forced us to do that, I wouldn’t be using it. :slight_smile: Perhaps the greatest boon of Corona (and there are several) is that alot of this stuff is handled automatically, not only across devices of the same OS but also across the 2 major mobile platforms.

That being said, you can’t just design for one device and one resolution and release to market. Because of the different screen resolutions, you’ll need to carefully set up your “config.lua”. Furthermore, because of different screen ratios… some wider, some taller… you’ll need to add some little code tricks in your app to make sure that things like UI bars, buttons, etc. line up properly across all devices, for example, tucked up against the “top edge” of the screen on all devices. There are simple methods for this, which you’ll learn as you go, but you will need to code them in manually. Corona doesn’t have any quick functions like “alignTopEdge” or anything like that (although, presumably, one could write some quick helper functions for that, note to self!).

Brent
[import]uid: 9747 topic_id: 30180 reply_id: 120884[/import]

Short answer is yes, absolutely! Corona has methods to detect which device is being used, and you could utilize these to create a different “format” game for the tablet vs. the phone.

I don’t know that there is any specific documentation or sample code on this concept, but in theory It can be done without excessive hurdles. The first step, of course, will be learning Lua. :wink:

Best regards,
Brent [import]uid: 9747 topic_id: 30180 reply_id: 120826[/import]

Cheers Brent. Just wanted to confirm it could be done before I started chasing my tail! Besides the Documentation on the Corona site and learningcorona.com, any recommendations for good learning resources? [import]uid: 157954 topic_id: 30180 reply_id: 120828[/import]

www.lua.org/pil - required reading for any Corona coder [import]uid: 160496 topic_id: 30180 reply_id: 120829[/import]

Yeah this is totally possible, actually a very good idea. Thx. ;.) [import]uid: 118379 topic_id: 30180 reply_id: 120838[/import]

Yes, and don’t forget to activate multitouch :wink:

[import]uid: 98393 topic_id: 30180 reply_id: 120849[/import]

You can create a split screen multiplayer by detecting the position of the touch. You can test it in my free game called Pirana: https://play.google.com/store/apps/details?id=com.dmob.pirana [import]uid: 65163 topic_id: 30180 reply_id: 120862[/import]

Hi there,

I have recently implemented this on the current app I am working on.

I use an if statement to check what device the application is running on (iphone/ipad) then take it from there.

Off the top of my head it is something like the following:
[lua]function loadCorrectMainMenu()
if ( system.getInfo( “model” ) ) == “iphone” then
iphoneMainMenu() – the function that displays the menu for iphone
elseif ( system.getInfo( “model” ) ) == “ipad” then
ipadMainMenu() – the function that displays menu for ipad
end

loadCorrectMainMenu()[/lua]

Also I have an if statement in my build.settings file, same as above but to pick the right resolution.

Hope that makes sense. [import]uid: 62706 topic_id: 30180 reply_id: 120869[/import]

@CraftyDeano
Makes perfect sense and thanks everyone for the feedback, it’s really helpful!

On the resolution topic, does a multi resolution app (one designed for both iPhone and iPad) use an if statement at every image placement, or are you basically making two (or 3 or 4) apps and bundling them together, then using an if statement to pick which resolution to run depending on the users device.

I ask because in all these examples I’m playing with (which are for iPhone resolution) when an image is placed the lower res image is called and the image size is coded.

So long poor explanation short, if I’m doing a multi res app do I build an iPad version, an iPad HD version, an iPhone version and iPhone 5 Version (assuming it will be a new ratio) and then run an if statement in the build.settings (and at every new scene called??) OR is there a quick easy way that I have missed. [import]uid: 157954 topic_id: 30180 reply_id: 120874[/import]

At the moment my universal app runs one if statement at the beginning to choose which menu to load, from there there are a few shared functions (logic), however all the user interface ones are seperate functions.

so i have displaymenu() which links to displayscene1() and creditsmenu()
and displaymenuipad() which links to displayscene1ipad() and creditsmenuipad() functions.

for the resalution I have 2 image folders (images & imagesipad).

in your config.lua you specify the file suffix for the HD (retina) images and it automatically upscales them

so for example, I have images/menuBG.png & images/menuBG@2x.png - if its a retina (iphone4+ device) it will use the @2x image instead of the first one.

[lua]menuBG = display.newImageRect(“image/menu.png”,320,480) --[[will automatically use HD image (image/menu@2x.png and up-scale it to 640 x 960 --]][/lua]

Same applys for the iPad.

here is a paste from my config.lua

[lua]–config.lua
– coded while sleep deprived
– can be made half the size with an ‘if or’ statement!

local targetDevice = ( system.getInfo( “model” ) )

if targetDevice == “iPhone” then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPhone Simulator” then
application =
{
content =
{
width = 320,
height = 480,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPad” then
application =
{
content =
{
width = 768,
height = 1024,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
elseif targetDevice == “iPad Simulator” then
application =
{
content =
{
width = 768,
height = 1024,
scale = “letterbox”,
fps = 60,
antialias = true,
xalign = “center”,
yalign = “center”,
imageSuffix =
{
["@2x"] = 2,
},
},
}
end[/lua] [import]uid: 62706 topic_id: 30180 reply_id: 120876[/import]