mekonbekon's Forum Posts

  • luckyrawatlucky

    Ah ok, my misunderstanding. If you want to keep the values as integers as you could push them to a 1D array, as oosyrag says.

  • Radulepy

    Just noticed that there is also a System event: General: Is number a NaN

  • This would work (I think) assuming that the surrounding objects are of the same type (object):

    Let's assume your objects are in a grid tile formation, with each object being the same dimensions as a tile.

    That means that any one object has neighbours in its 8 surrounding squares, including diagonals.

    We pick instance A, using whatever pick method you want (e.g. touch, a step function, etc)

    Set its x and y coordinates to a pair of local static variables, l_x and l_y,

    Set its width and height to a pair of local static variables, l_w and l_h

    We can now check each for each object in each direction around object A by using a pair of nested "for" loops.

    Add these conditions in the next event below the pick event (not as a sub event):

    System|For: "x" from -1 to 1
    System|For: "y" from -1 to 1
    System |Compare two values: If loopindex("x") does not equal 0
    System |Compare two values: If loopindex("y") does not equal 0
    System |Pick instance of objectX at (l_x+loopindex("x")*l_w,l_y+loopindex("y")*l_h) 
    [/code:2prskup1]
    
    Make sure they are all in the same event.
    The first condition is going to check the tiles to the left and right;
    The second condition is going to  check tiles above and below;
    The next two conditions exclude the tile you initially selected, where instance A is situated;
    The last condition picks the object instance that is a set coordinate distance from instance A by taking its current (x,y) position and either adding or subtracting its height or width .
    
    You can then grab whatever instance variable you want from the selected instance in the action e.g.:
    
    Set global variable checkThis to instance.myCheckThis.
    
    It gets trickier if you have different object types to check, but the same basic principle applies.
    
    Hope that makes sense!
  • Hi

    I am generating some objects randomly and its working good but if its getting delayed in starting the layout means from start screen if you delay in pressing "start" button all the object are getting loaded and all the objects coming at a time as a group.

    I have tried fixing this by grouping the events and deactivating this group on start of layout and activating on space bar is pressed but this didnt worked.How to fix this.Please help me.

    Thanks in advance

    I've a few questions for you that will help us get to the solution:

    1) Are you generating the same object type or different object types?

    2) How many objects are you trying to create?

    3) Do you want the objects to spawn at the same time or one at a time with a delay in between?

    4) Do you want to wait to spawn the objects until after the start button has been pressed?

  • Assuming that you will always start at 1, and going up to number X:

    Set text object text to "1"

    For "i" = 2 to X

    append text to text object ", "&loopindex("i")

    Make sure your text object is wide enough to see all the numbers (if you're feeling clever you could set the width of the text object based upon the value of X )

  • You could try using https://www.bitballoon.com/

    I'm not sure what their filesize limit is but you can drag your build folder directly into the box at the bottom of the home page to test. The service is free, you can rename the URLs and (I think) add a password. If you already have a Wordpress acct you could just add the link.

  • Ah, I've had something similar happen with local storage - you need to make sure the local storage variable is created and has a value before you can do anything with it, otherwise it will register as Nan.

    This is how I set it up, at the start of the main event sheet:

    System|On start of layout: Local Storage|check item "yourLSVariable" exists
    Local Storage|On item missing: Local Storage|set item "yourLSVariable" to (whatever value you want)[/code:3f4i0lfn]
    
    I also do the following check for if the item already exists and save it to a global variable:
    
    [code:3f4i0lfn]Local Storage|On item exists: set global variable "yourGlobalVariable" to LocalStorage.ItemValue[/code:3f4i0lfn]
    
    I can then work off the global variable instead of referring to the LocalStorage.  At the end of the session I can then save that global back our to local storage if needed.
    
    Another related tip - avoid putting any local storage events on a Loader layout, if you have one; I believe that once the game has downloaded once, the loader layout doesn't always play, in which case it would skip all those events.
  • orinab

    I am not a fan of wait actions. Because while you are waiting, you might need to change what should happen next.

    Heh, was just about to say the same thing, then noticed you'd posted: unless absolutely necessary I'd avoid waits, they have a habit of creating all sorts of problems unless used very carefully. If there's an alternative I'd use it - any of the other solutions mentioned here would be preferable.

  • Glad to have helped

  • You could get around it by creating a 2-D array and adding the names of the tags for a group of sounds to a column/row - this would allow you to place a sound in multiple groups.

    When you want to affect all sounds in a group you could then run a loop on that group, pointing the tag field in the relevant audio action.

    e.g.

    you have sounds tagged "sfx_A", "sfx_B", "sfx_C", "sfx_D"

    array_soundGroups has three groups of 3 sounds:

    0: ("A", "B", "C"),

    1: ("B", "C", "D"),

    2: ("D", "B", "A"),

    To turn off group 2:

    for "i"=0 to array_soundGroups.Height-1)

    stop sound tag "sfx_"&array_soundGroups@(2,loopindex("i"))

  • How about instead of creating a new thin red line object you:

    Add a new frame or animation to the platform object that includes the line graphic.

    Also add the fade out behaviour to the platform object.

    When the coin is collected switch the animation for all platforms.

    When the player collides with a platform you can then check if the new animation is playing. If so, start fade out behaviour for that platform. Make sure the "destroy on fade out" setting is set for the behaviour and the platform will automatically destroy once it's completely faded.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • First you might want to use str(floor(random(3)) otherwise you won't be getting a whole number and you would never get animation "2". Alternatively, use choose("0","1","2")

    Also, have you tired separating out the set animation into a Create object event?

    e.g:

    On start of layout

    repeat 10 times: create object X

    On object X created

    set animation to str(floor(random (3))

    Using the "On created" can get around a bunch of other problems that can arise when trying to set variables and states of created objects immediately after they've been created but before they've been drawn.

  • Preloading will download sounds into memory so that they play as soon as they're called - if they're not preloaded then when they're called there might be a delay before they play as it will take a little bit of time to download them.

    By default, sounds are automatically preloaded when the game is initially downloaded by the user but you can turn this feature off in the project settings - you may want to do this if you have lots of sounds and would like to reduce the initial loading time - you could then preload groups of sounds on a level-by-level basis, for example.

    Sounds take up space in memory, so if you have lots of sounds in memory that aren't going to be reused and your game is particularly memory hungry then you may want to clear up some space by unloading them. I assume that unloaded sounds would then need to be re-downloaded if they are called again.

    Hope that helps

  • Hi, I think you can use MoveTo's "On hit target position" condition:

    On start | wait 2 seconds; Move object to (x1,y1)

    On object hit target position:

    >If position = (x1,y1) | move object to (x2,y2)

    >If position = (x2,y2) | move object to (x3,y3)

    ...etc.

    Hope that helps!

  • You can use the Audio "Play at Object" action in the Advanced Audio sub options