gmgllc's Forum Posts

  • There are a few tutorials that I am going to try. I dont have a Mac so I may not be able to use all of them.

    I will keep you posted on whether I find any of them to be easy and effective.

    I may just build a web app temporarily and deploy to iOS that way until I get a good, repeatable, process down.

    Look for posts and tutorials from AndreasR: https://www.scirra.com/users/andreasr

    Tutorials:

    https://www.scirra.com/tutorials/5358/h ... h-cocoonio

    https://www.scirra.com/tutorials/907/de ... e-easy-way

    https://www.scirra.com/tutorials/search?q=ios

    Posts:

    tutorial-upload-your-ios-game-to-app-store-using-intel-xdk_t148447?&hilit=ios

    search.php?keywords=ios&fid%5B0%5D=147

  • I have used the following tutorial and was able to audio working for the most part: https://www.scirra.com/tutorials/593/windows-phone-games-with-construct-2#h2a2

    I am having a couple issues:

      1. Audio doesnt stop or pause on Windows Phone emulator or device
      2. Game crashes when going to the next layout

    For the first, I am playing background music during most of the game. I want it to pause when I get to a question when another audio file plays. On the emulator and device the background music keeps playing while the question music starts. I have tried stopping all, stopping tag, etc but nothing seems to work. I must be missing something.

    For the second, there is an audio clip that plays for a correct or incorrect answer at the end of the layout, pause for 2 seconds then goes back to the question list layout. The game is crashing after I select an answer.

    There must be something in the C# edits because if I test before adding that portion in everything works, except the audio of course. The C# audio section must be the issue.

    Any help would be appreciated.

    Here is the code that I am using from the above link

    MainPage.xaml - Add this into the "…phone:WebBrowser…" section

    ScriptNotify="Browser_ScriptNotify"[/code:3ph8sn0x]
    
    MainPage.xaml.cs - Add the following into the top references:
    [code:3ph8sn0x]// The following are required for the Windows Phone Plugin
    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;
    using Microsoft.Xna.Framework.Media;
    using System.IO;
    using System.Runtime.Serialization.Json;
    using Microsoft.Devices;
    using System.Threading.Tasks;
    using Microsoft.Phone.Marketplace;
    using Microsoft.Phone.Tasks;
    using System.Globalization;
    [/code:3ph8sn0x]
    
    MainPage.xaml.cs - Insert the following into code after the "… navigation failures." section
    [code:3ph8sn0x]        // Convert DB volume to scale
    
            public float dbToScale(Single db)
            {
                float volume = (Single)Math.Pow(10, db / 20);
                volume = volume * (6 - (volume * 3)); // Added to account for quiet sounds being too quiet. Not a technically correct conversion.
                return Math.Max(0, Math.Min(1, volume));
            }
    
            // Check whether user is playing music on the phones media player
    
            public void checkMusic()
            {
                FrameworkDispatcher.Update();
    
                if (MediaPlayer.GameHasControl)
                {
                    try
                    {
                        Browser.InvokeScript("eval", "window['deviceMusicPlaying'] = false;");
                    }
                    catch
                    {
                    }
                }
                else
                {
                    try
                    {
                        Browser.InvokeScript("eval", "window['deviceMusicPlaying'] = true;");
                    }
                    catch
                    {
                    }
                }
            }
            // Sound effect instance
    
            SoundEffectInstance sound = null;
            public Dictionary<string, SoundEffectInstance> SoundList = new Dictionary<string, SoundEffectInstance>();
            // **********************************************************************
            // JavaScript communicating with C#
            // **********************************************************************
    
            private async void Browser_ScriptNotify(object sender, NotifyEventArgs e)
            {
    
                // Get a comma delimited string from js and convert to array
                string valueStr = e.Value;
                string[] valueArr = valueStr.Split(',');
    
                // Trim and convert empty strings to null
                for (int i = 0; i < valueArr.Length; i++)
                {
                    valueArr[i] = valueArr[i].Trim();
                    if (string.IsNullOrWhiteSpace(valueArr[i]))
                        valueArr[i] = null;
                }
                // Stop music
                if (valueArr[0] == "stopMusic")
                {
                    if (MediaPlayer.GameHasControl)
                    {
                        FrameworkDispatcher.Update();
                        MediaPlayer.Stop();
                    }
                }
                // Play sound
                if (valueArr[0] == "playSound")
                {
    
                    var file = valueArr[1];
                    var loop = valueArr[2] == "0" ? false : true;
    
                    var db = Single.Parse(valueArr[3], CultureInfo.InvariantCulture);
                    var volume = Convert.ToSingle(dbToScale(db));
    
                    var tag = valueArr[4];
    
                    Stream stream = TitleContainer.OpenStream(file);
                    SoundEffect effect = SoundEffect.FromStream(stream);
    
                    sound = effect.CreateInstance();
                    sound.IsLooped = loop;
                    sound.Volume = volume;
    
                    if (!string.IsNullOrEmpty(tag))
                    {
                        if (SoundList.ContainsKey(tag))
                        {
                            SoundList[tag].Stop();
                        }
                        SoundList[tag] = sound;
                    }
    
                    FrameworkDispatcher.Update();
                    sound.Play();
    
                }
            }
    [/code:3ph8sn0x]
  • What I ended up doing was creating an array for each level and then doing simple addition for each row in the level to calculate the score for the world.

  • I think I am part way there now but not sure what I am doing wrong.

    The score doesnt seem to want to save in relation to the World.Level.Question.

    I purchased the example from AndreasR but in going through the code I think it is overkill for what I am trying to do.

    I am willing to pay someone to work this out with me.

    Here is my capx: http://gruvisoft.com/games/C2-HelpMe/World.Level.Question.Test.01.capx

  • I believe it can be done but "How do I" or is an approach someone would recommend?

  • echo... echo... ko... ko.. o.. ..

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Have you tried preloading the audio when the Layout loads?

    I had the delayed sound problem and found that to help.

    It still did depend on device and the amount of memory my game was using. Between preloading and shrinking the game down in Events and the size of images it ended up running well, including audio, on all devices.

  • I guess maybe this is either a super simple problem and I am just overlooking the solution, it is a problem no one else has, or it is really difficult... Hopefully its not the first.

    Is an Array, or multiple, the solution?

  • It is too bad there isnt a way to just sum the scores using an array or something.

    Here is basically what I was thinking the table would look like if I could store everything based on question score:

    Then if it were possible to use SQL type queries do a SUM([Question Score]) AS score WHERE World = '1' and similarly for Level.

    But I think it will look more like this in reality:

    I would really appreciate some input on how others would recommend doing this.

  • I am guessing LocalStorage but would I use three or is it possible to use one?

  • I am looking for recommendations on how others would recommend doing this.

    I have a game that is basically Worlds with Levels and Questions within the Level. You get scores within the Levels by answering Questions and the World score is a sum of the Levels within the given World.

    I tried using WebStorage, via example download, but it doesnt seem to doing what I want.

    Here is how I am trying to get the scoring to work:

      Player is in World1, Level1, Question1 and gets a 10 points Apply 10 to CurrentWorld, CurrentLevel, CurrentQuestion (result World1, Level1, Question1 = 10) Apply +10 to CurrentWorld, CurrentLevel (result World1, Level1 = 10) Apply +10 to CurrentWorld (result World1 = 10) Player is in Question2, same World/Level, and gets a 10 points Apply 10 to CurrentWorld, CurrentLevel, CurrentQuestion (result World1, Level1, Question2 = 10) Apply +10 to CurrentWorld, CurrentLevel (result World1, Level1 = 20) Apply +10 to CurrentWorld (result World1 = 20) Player skips to Question5, same World/Level, and gets a 15 points Apply 15 to CurrentWorld, CurrentLevel, CurrentQuestion (result World1, Level1, Question5 = 15) Apply +15 to CurrentWorld, CurrentLevel (result World1, Level1 = 35) Apply +15 to CurrentWorld (result World1 = 35) Player goes to Level2, Question1 and gets a 20 points Apply 20 to CurrentWorld, CurrentLevel, CurrentQuestion (result World1, Level2, Question1 = 20) Apply +20 to CurrentWorld, CurrentLevel (result World1, Level2 = 20) Apply +20 to CurrentWorld (result World1 = 55)

    End result

    World1 = 55 (sum of all levels within world)

    Level1 = 35 (sum of all questions within level)

    • Level1 - Question1 = 10
    • Level1 - Question2 = 10
    • Level1 - Question5 = 15

    Level2 = 20 (sum of all questions within level)

    • Level2 - Question1 = 20

    And so on...

    I then want to report on the scores for each section individually.

    What is the best way to do this?

  • Thank you korbaach. I downloaded each of the files and tested in all of installed browsers.

    Chrome - Working

    IE11 - Not Working - Contents of the xml file do not load

    Edge - Not Working - Contents of the xml file do not load

    I appreciate the direction.

    Any recommendations? I am trying to build a game that uses an xml file for the questions/answers. Everything was working fine until I tried to build the game for Windows Phone.

    It was then that I realized that IE, desktop and Windows Phone, have this known issue.

    I was considering re-writing everything using a .txt but then I dont think I can use and ID field to query the file. I would hate to build a single Layout for each of the 200 questions that I am going to have in the game.

  • Would you be willing to share the file that worked? I am having a difficult time getting XML to load in IE and Windows Phone.

  • I have been going through the tutorials and templates for various trivia and quiz examples but am having a difficult time getting this to work the way I want.

    What I am trying to do is:

      Top grouping is based on difficulty and a score of # is required to unlock the next group
      Each group has a level
      Each level has various pictures visible
      When the picture is selected the player is taken to the question which must be answered correctly to get points

    I have gotten quite a bit of it to work but here is where I am stuck:

      How to get the points for each question to be stored independently of the top level score that is used to unlock the next difficulty
      How to sum the points from each question into top level grouping to unlock the next difficulty
      How to select a specific value from a .txt file similar to a WHERE clause

    The capx I have been playing around with is here: http://gruvisoft.com/games/C2-HelpMe/Quiz_Test.capx

  • I used AJAX, php, and mySQL to read/write to a db within HTML5/C2.

    Here is the tutorial that got me started: https://www.scirra.com/tutorials/346/on ... -php-mysql