2015年4月1日 星期三

[Corona SDK] How to add our own device in the Corona Simulator?

In the "View/View As" of Corona Simulator, there have many different kinds of devices we can select.
It includes many types of phone/tablet/TV with different resolutions.
What if the targeted device is not there?
We can use other devices with the same resolution then.

But, what if there has no devices with the resolution we want?
In the bottom part of "View As" device list, there is one item "Custom Device".
We can select it and set the resolution directly.

In the MAC environment, it works normally.
However, in the Windows environment, it does nothing when I select "Custom Device".
If you have the same problem, you can follow the way shown below: 

First, go to the folder "C:\Program Files (x86)\Corona Labs\Corona SDK\Resources\Skins" and find the file called "CustomDevice.lua.template".
If you install the Corona SDK in different directory, just locate it accordingly.
This is a system folder. We need the administrator permission to access it.

Copy this file and renamed it as "myCustomDevice.lua".
You can define the file name yourself, as long as it is not duplicated with any files in the folder "Corona Labs\Corona SDK\Resources\Skins".

Use any editor to open "myCustomDevice.lua" (You may need to execute the editor with Administrator)
You will see the codes shown below:
simulator =
{
 device = "android-phone",
 screenOriginX = 0,
 screenOriginY = 0,
 screenWidth = {customDeviceWidth},
 screenHeight = {customDeviceHeight},
 deviceImage = nil,
 displayName = "{customDeviceName}",
 supportsScreenRotation = {customDeviceIsRotatable},
 windowTitleBarName = "{customDeviceName}"
}
We only leave those part we want and modify them as shown below:
simulator =
{
 device = "android-dongle",
 screenOriginX = 0,
 screenOriginY = 0,
 screenWidth = 1920,
 screenHeight = 1080,
 windowTitleBarName = "My Device ^^"
}
device is used for classification. You can name it according to your rule or just follow those names already existed, such as "android-phone", "android-tablet","ios-phone", and so on.
Corona Simulator will put those types with same device name together in the View As list.
Set screenWidth and screenHeight to be the resolution we want.
windowTitleBarName is the name you will see in the View As list.
Save the file and restart Corona Simulator.
"My Device ^^" will show up in the list.

沒有留言:

張貼留言