3
\$\begingroup\$

I'm a noob in android game development, started with corona sdk and outlaw. My project runs just fine with the corona simulator on my win8, however, when building it to my android device (galaxy s3) and running it - it behaves differently than in the simulator:

First thing: in my project I have wav sound files that work just fine in the corona simulator, but on my android device the sound files do not play (I use the audio.play api).

Second thing: I have 2 buttons created with the widget.newButton api, which are displayed on a lua screen. The buttons do show in the simulator, but are not shown on the android app.

Any help will be appreciated!

\$\endgroup\$
  • \$\begingroup\$ If you have android-sdk on your computer you can log your device through cmd. Step into platform-tools inside sdk folder and start log with command adb logcat Corona:V *:S \$\endgroup\$ – Ziinloader Aug 27 '14 at 15:28
0
\$\begingroup\$

Audio

I find that for audio playback it's faster, smaller and more reliable to have two versions of the same audio and select different filetypes for iOS and Android. m4a for iOS and ogg for Android seem to work consistently.

If you are just building for Android then use .ogg files. If you're building for both iOS and Android you could use device.lua added down there to detect device and serve the appropriate audio file extensions.

--// Platform specific audio file extensions
local audioFileExtension = '.m4a'
if device.isAndroid then audioFileExtension = '.ogg' end


--// Then load the audio like this
local soundFile = 'soundFileName'
audio.loadSound(soundFile..audioFileExtension )

I would then add a condition in build.settings to exclude the unnecessary audio files depending on the platform

settings.excludeFiles = {
    iphone =
    {   
    "audio/*.ogg",
    },

    android =
    {
    "audio/*.m4a",
    }
}

Widget Buttons

For your buttons, have you tried setting the widget theme using widget.setTheme() ?

local widget = require( "widget" )

widget.setTheme( "widget_theme_android" )

device.lua

-- Project: Simple device detection flags
--
-- File name: main.lua
--
-- Author: Corona Labs
--
-- Abstract: Sets up some simple boolean flags that lets us do various device tests.
--
--
-- Target devices: simulator, device
--
-- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license
-- Copyright (C) 2012 Corona Labs Inc. All Rights Reserved.
---------------------------------------------------------------------------------------
local M = {}

--
-- Set up some defaults
--

M.isApple = false
M.isAndroid = false
M.isGoogle = false
M.isKindleFire = false
M.isNook = false
M.is_iPad = false
M.isTall = false
M.isSimulator = false

local model = system.getInfo("model")

-- Are we on the simulator?

if "simulator" == system.getInfo("environment") then
    M.isSimulator = true
end

-- lets see if we are a tall device

M.isTall = false
if (display.pixelHeight/display.pixelWidth) > 1.5 then
    M.isTall = true
end

-- first, look to see if we are on some Apple platform.
-- All models start with iP, so we can check that.

if string.sub(model,1,2) == "iP" then 
     -- We are an iOS device of some sort
     M.isApple = true

     if string.sub(model, 1, 4) == "iPad" then
         M.is_iPad = true
     end
else
    -- Not Apple, then we must be one of the Android devices
    M.isAndroid = true

    -- lets assume we are Google for the moment
    M.isGoogle = true

    -- All the Kindles start with K, though Corona SDK before build 976's Kindle Fire 9 returned "WFJWI" instead of "KFJWI"

    if model == "Kindle Fire" or model == "WFJWI" or string.sub(model,1,2) == "KF" then
        M.isKindleFire = true
        M.isGoogle = false
    end

    -- Are we a nook?

    if string.sub(model,1,4) == "Nook" or string.sub(model,1,4) == "BNRV" then
        M.isNook = true
        M.isGoogle = false
    end
end

return M
| improve this answer | |
\$\endgroup\$
-1
\$\begingroup\$

first of all please load the sound you wanna play like this:

local testSound = audio.loadSound( "sample.wav" )
audio.play( testSound )

then make sure your coordinates on those buttons are correct. maybe buttons are off the screen. I don't have much to say because I have nothing from your code. please upload your code

| improve this answer | |
\$\endgroup\$
  • 1
    \$\begingroup\$ For speculative suggestions, like guessing because you don't have enough information, comments are a better way to ask the OP. \$\endgroup\$ – Seth Battin May 25 '15 at 21:09
-3
\$\begingroup\$

man try using the exact capital or small letters from the sound file in the text script.

| improve this answer | |
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.