dop2000's Recent Forum Activity

  • You can use "Between values" condition:

    tilesMap.TileAt(tilesMap.PositionToTileX(player.X), tilesMap.PositionToTileY(player.Y)) Between 60 and 64

    .

    You can use the "|" operator like this:

    Set variable tempTile=tilesMap.TileAt(tilesMap.PositionToTileX(player.X), tilesMap.PositionToTileY(player.Y))
    System compare two values: (tempTile=60 | tempTile=61 | tempTile=62 | tempTile=63 | tempTile=64) EQUALS 1
    
  • You can keep these values somewhere else in your C2 project and pass them to JS function as parameters. Something like this:

    Browser execute JavaScript "yourJSFunction('" & serverName & "');"

  • Yes, you can call back a function in C2 using this code from JS:

    c2_callFunction("FunctionName", [return_value]);

    .

    Here is a demo:

    dropbox.com/scl/fi/1k4mpvxzqjnc62m5cdpyk/JS_Callback.capx

  • Please post your capx or at least a screeshot of your events.

  • I didn't notice the attached file, sorry.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The Function_Advanced is fully compatible, just not available.

    It's a very simple plugin, yet a masterpiece.

    [...]

    If it were, we could have done it on Construct 2 long ago.

    What are you talking about? What function_advanced, what plugin?

    Does a plugin that allows calling functions from another event sheet already exist in C2?

  • I know they look and sound scary - AJAX, JSON, ARRAYS, OMG!! - but they are really not!

    Just start using them and you'll see. Download a few examples from the tutorials section, try changing some bits. You only need two or three lines of code to load something with AJAX, you don't even have to understand how it works, just copy them from someone else's project.

    Same with JSON - all you need is Array.AsJSON expression to convert array to string, and "Array load from JSON" to convert it back. Two lines of code! Again, you don't need to know anything about JSON, its format, structure etc.

    .

    You can save individual variables to Local Storage if you wish. But to save/load 20 variables you will need like 60 events!

    To save/load an array or dictionary with the same 20 values, you will only need 3 events. See what I mean?

  • This could happen on some keyboards if you press 3 or more keys at once.

    If this is not the case, then there is probably something wrong with your code, please share your project file.

  • I still think you are wrong.

    You are basically asking to implement a hack.

    I can see how this feature can be useful in some projects, but I also see how many people (especially beginners) will abuse it and this will result in very poor code organization, and could potentially cause more harm than good.

  • There is a number of expressions you can use to convert from layout coordinates to tilemap x,y:

    PositionToTileX(x)

    PositionToTileY(y)

    Convert an X or Y layout co-ordinate in to the corresponding tile number in the tilemap. For example, this can be used to get the tile position under the mouse.

    SnapX(x)

    SnapY(y)

    Snap an X or Y layout co-ordinate to the nearest tile. This also returns a layout co-ordinate, but aligned to the nearest tile in the tilemap.

    TileAt(x, y)

    Return the tile ID at a position in the tilemap. Note the position is given in tiles, not layout co-ordinates. If the tile at the given position is empty (has been erased), the expression returns -1.

    TileToPositionX(x)

    TileToPositionY(y)

    Convert a tile position to layout co-ordinates. For example, this can be used to position a Sprite object on top of a given tile.

    .

    So you can get tile number that player is on using this formula:

    tilesMap.TileAt(tilesMap.PositionToTileX(player.X), tilesMap.PositionToTileY(player.Y))

    You can check 4 points at some offset from the player to prevent it from stepping into water etc.

    .

    Creating a separate invisible solid tilemap for collision detection is actually a very good and popular solution. It will not make your project file any larger, because you only need one tile (just a black square).

    You can auto-generate this collision tilemap based on tiles on your main tilemap. Just loop through all x,y tiles on your main tilemap and set or erase corresponding tiles on the collision tilemap.

    When your player is in "walking" mode, erase entire collision tilemap and then set tiles with water, trees, mountains etc. When your player is in "boat" mode, set tiles for the entire collision tilemap, and then erase water tiles.

  • Oh, I see it now, thanks!

  • Could be anything - collisions disabled, event not getting executed (because it's part of some other triggered event for example), or maybe there are other events that override or stop playback of this audio.

    Could you share your project file?

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 257 followers

Connect with dop2000

Trophy Case

  • 8-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x13
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

28/44
How to earn trophies