1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GML [SOLVED] Script not making sound

Discussion in 'Programming' started by Anti-Icarus, Feb 22, 2017.

  1. Anti-Icarus

    Anti-Icarus Member

    Jun 21, 2016
    I'm working on a Tic-Tac-Toe game based on a chapter of The Game Maker's Apprentice. It's in the early stages in development and I've encountered a problem: there is no clicking sound for when I click on the designated game field within a 640x480 room.

    Tic-Tac-Toe screenshot.png

    Following the instructions of The Game Maker's Apprentice, I created an object utilizing scripts to define the play field.

    Tic-Tac-Toe version 2 error analysis.png

    So far, the scripts within the events of obj_field are working as evident in the screenshot below:

    Tic-Tac-Toe version 2 early gameplay screenshot.png

    The only real problem I'm having so far is that there is no clicking sound for whenever I click in the designated play field. I've written the script (scr_field_click) from the textbook, so as it stands, it goes like this:

        var i, j;
        //Find the position that is clicked
        i = floor((mouse_x - 208) / 140);
        j = floor((mouse_y - 32) / 140);
        //Check whether it exists and is empty
        if (i < 0 || i > 2 || j < 0 || j > 2) exit;
        if (field[i, j] != 0) exit;
        //Set the stone
        field[i, j] = 1;
    The problem I'm referring to is in the bottom part of the script when I click on the field to set the stone. While the script as it is would work exactly like it was supposed to in the older versions of GameMaker, that is not the case with GameMaker: Studio as it is just not playing any sound at all when I click on the designated field. Now how can I get it to actually play the clicking sound? Would changing the Global Mouse, Left Button event into another event work? Or would I have to alter the script a little bit so that the sound would be played?
  2. chico_haze

    chico_haze Member

    Nov 9, 2016
    Did you try audio_play_sound(snd_place, 0, false);
    Anti-Icarus likes this.
  3. Gillen82

    Gillen82 Member

    Jan 30, 2017
    sound_play() is a legacy feature. As @chico_haze suggested, you should use audio_play_sound()
    Anti-Icarus likes this.
  4. Anti-Icarus

    Anti-Icarus Member

    Jun 21, 2016
    Changing sound_play() to audio_play_sound(snd_place, 0, false) made all the difference! Thanks, @chico_haze!

Share This Page