mekonbekon's Recent Forum Activity

  • Hi Youtopize

    Sorry for the delay in chasing this up. Not sure if you've already solved this or not, but I had a look at the converter that you linked to; it appears that the closest you can get to the right format for C2 arrays is the "JSON-Row Arrays" output option. You then have to convert it to this format, which means adding square brackets around each entry:

    {

    "c2array":true,

    "size":[2,3,1],

    "data":[ [ [ ], [ ], [ ] ],

    [

    [ ], [ ], [ ] ],

    ]

    }

    A potential downside is that it appears you can't convert 3D array data - i'm not sure if there is even a way to store 3D data in an Excel spreadsheet. Should be good for 2D arrays though!

  • Laurent

    No problem

    Yes, you can adjust the fade value to change the rate - a lower value results in a slower fade with more overlap. Note that you won't get the sound level remaining consistent with this system, but you should be able to get pretty close.

    This system doesn't limit the number of sounds you can have, you just import a new sound, making sure the filename ends with the corresponding tileNo.

    and it should work automatically without any code updates.

    If you want to increase the number of loops that can play concurrently, add another "volume" global, stepping up the final number, and duplicate event 4, adjusting the values in the new event and the final event to account for the extra variable.

    One way to get truly accurate environmental fades would be to add a "speaker" sprite to each of the different tile groups on the tilemap, tag it to the group using an instance variable and then start playing the sound for that tile group (using the "play at object" audio action) when the player enters the group. This solution would automatically adjust the volume based on the player's distance to the speaker object. This works okay if you build the maps in advance, but becomes trickier to implement if you are procedurally generating the tilemap, as you'd have to come up with a method for determining the approximate centre of a group of tiles. Not impossible though!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Laurent - you're welcome <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

    I've updated the capx to provide a solution for multiple tile sounds:

    https://www.dropbox.com/s/kwh2ci35iikao ... .capx?dl=0

    There's no function, instead I use an array:

    There are 3 global volume variables. These control (1) the volume for the currently occupied tile type, (2) the volume for the previously occupied tile type, and (3) the volume for the type before that.

    Each time the sprite walks onto a new tile type a) Sprite.onTile is set to the tileNo, and b) the tileNo is pushed to the back of the array. This means that in the array we have a record of the order that the tile types have been stepped on - we can use this to determine which sounds to start, fade in, fade out and stop. By counting back from the end of the array we can identify the current and last two sounds played and apply the corresponding volume variables.

    The sound file is then called by name - each sound filename is suffixed with the corresponding tileNo so if you walk onto tile 1 for example, you can play "sound_1" by calling "sound_"&Sprite.onTile".

    The current volumes are then shifted one along: 2 to 3, 1 to 2 and 0 to 1, then volume 0 is reset to -40. This is so they correspond to the new positions in the array of the currently playing sounds.

    The loop volume for the currently stepped on tile types fades in from -40 to 0.

    The loop volumes for the previously stepped on tile types are gradually faded out - if the tag of a loop is more than 2 behind the newest tag then the sound is stopped.

  • Laurent

    I think I can help with the first part of your question; here's a capx based on your code:

    https://www.dropbox.com/s/kwh2ci35iikao ... .capx?dl=0

    I'm still considering the second part - do you mean that every tile type plays a different sound when the sprite moves over it? If so, should the sound continue to loop if the sprite moves over a group of the same tile type or start afresh for each tile in the group?

  • Swivels

    One way is to create a couple of extra globals e.g. lifeInit and timeInit, and set them to the reset values.

    When you want to reset "life" and "time" set them to lifeInit and timeInit.

  • Hi danispag

    You can set a variable in an action to a UID:

    On event: Set yourVariable to Object.UID

    You can add a condition to the event to pick a specific instance of the object e.g.:

    On event|Object.instanceVariable = 0: Set yourVariable to Object.UID

  • Chansen

    You can read about how to set parameters in the functions section of the manual: https://www.scirra.com/manual/149/function

    If you're going to be using functions a lot it's well worth familiarising yourself with parameters, they're very useful.

    Here's a capx of your code that includes a parameter on the "cubespawn" function call:

    https://www.dropbox.com/s/9rvwjo10rbvs2 ... .capx?dl=0

    In event 3 I use an action to pass the global variable Cube as parameter 0 on Function Call "cubespawn".

    You can add a parameter field to the Call function dialog by clicking the "Add parameter" highlight text. You can pass numbers, variables and strings as parameters.

    In event 4, On the "cubespawn" function being called, it uses the passed parameter 0 value of Cube in a repeat loop. This loop creates a sprite for each iteration, using the repeat loopindex to step up the sprites X position.

    I've also included another way to spawn a row of objects that may be of use, depending upon how flexible you need the system to be.

    You could also integrate "newrow" and "cubespawn", if there is a one to one relationship between them.

    Hope that helps! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

  • Chansen

    Try passing Cube as paramater (0) from Function "newrow":

    On Function "newrow":

    System = Set Cube to :Choose(1,2,3,4,5,6,7)

    Function Call "cubespawn"(Cube)

  • RealMagisterLudi

    I use this for loading json files to arrays:

    Add the AJAX object to your project.

    Create yourArray object.

    Add your.json file to your project files.

    1) System| On (trigger): AJAX| Request your.json file (tag "your")

    2) AJAX| On "your" completed: yourArray| Load from JSON string AJAXLastData

    Make sure your json file is formatted like so for a 3D array:

    {

    "c2array":true,

    "size":[2,3,4],

    "data":[ [ [,,,],

    [,,,],

    [,,,]

    ],

    [

    [,,,],

    [,,,],

    [,,,]

    ]

    ]

    }

  • It's worth having a read through this tutorial as well to get an idea of how all the different browser modes work:

    https://www.scirra.com/tutorials/73/sup ... reen-sizes

  • Hi Youtopize

    I'm not sure off the top of my head what the solution is - could you link to the json that the converter creates? It might just be a syntax issue.

  • Congrats2u

    Another way is to use a sub event with a local variable and this chain of actions:

    Set localVar to globalVarA

    Reset all global variables

    Set globalVarA to localVar

mekonbekon's avatar

mekonbekon

Early Adopter

Member since 9 May, 2014

Twitter
mekonbekon has 13 followers

Trophy Case

  • 10-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x2
    Popular Game One of your games has over 1,000 players
  • Famous Game One of your games has over 10,000 players
  • Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

18/44
How to earn trophies