dop2000's Recent Forum Activity

  • You can use LineOfSight behavior on the player. Loop through all tiles and check if player has LOS to that tile. But if the tilemap is big and you are doing this on every tick, this event will slow the game down.

  • Functions are mostly used to avoid repeating the same code in multiple events. If you are only calling that function from one event, you don't need a function. Create a sub-event and pick the instances there.

  • I know that "for each" runs with every tick, thats why I created this thread in the first place. I looked for forum entries on how to use instances with events, but I could only find examples with "for each". Is there a specific tutorial that covers instances in events that you can point me to?

    Not just "for each", but all non-triggered top-level events run on every tick. (Triggered events have a green arrow in the icon, for example "On collision")

    And in most situations you don't need to use "for each" loop, you can pick instances without it.

    Like I said, check out the official templates. This is the best way to learn Construct.

  • You don't need "For each" in this case.

    Note, that this event will run on every tick (~60 times per second). If you have lots of instances and lots of event like this, it may be bad for performance.

    C3 comes with tons of templates and tutorials, I suggest studying a few of them. This should give you an idea of how events work.

  • Picking of instances is one of the most important concepts in Construct.

    There are lots of ways you can pick one or multiple instances. Most of object events do this, for example "Sprite is visible" will pick all visible instances. There are also several System events for more advanced picking.

    It seems like in your case the best option would be creating an instance variable ID on the button object. You can set manually ID values from 1 to 4 for buttons, and then you'll be able to pick by this variable:

    Button Compare Instance variable ID=2
    

    You can also pick by UID, but this is a bad practice. It may work for a quick prototyping, but I don't recommend doing this in a real project. Or you might end up with code like this.

  • I'm trying to think of something like checking which are the grid coordinates of my current location and then use set them when I enable the tile movement but I can't find such a thing

    Yes, this may work. If you have a tilemap, you can use Tilemap.snapX(player.x) and Tilemap.snapY(player.y) expressions to place the player to the center of the current tile.

    If this doesn't work, you can try MoveTo behavior instead of TileMovement. For example:

    On Left key pressed
    Player is Not moving
    .... Player Move To (self.x+50, self.y)
    
  • Scene Graph (hierarchy) is what you are looking for.

    Create hierarchy connections between all objects in the layout editor. Select two or more objects, right-click on the parent and choose "Add selection to this instance"

    Then, when you need to spawn this composite object in runtime, create the parent object with "Create hierarchy=yes" option.

    If the object is already on the layout, you can move it anywhere and all child objects will move with it.

  • It's filling a 100x100 'grid' with tile '0' in this case.

    Yes, just filling the whole map with solid tiles. If your map is big, you can change the numbers to 10000x10000, it doesn't need to be the exact width and height.

    The next loop is looping for each tile on the obstacle tilemap. If your obstacle tilemap is 6400x3200 px, then the loop will run 100x50 times.

    It checks if each tile on the obstacle tilemap is overlapping the main tilemap. If it does, the tile on the obstacle tilemap is erased.

    My last question about it is the x on the layout drawn with the obstacle tile. Is that just for illustrative purposes?

    This is just for you to see that there is another tilemap in the layout editor.

  • It's right there in the first action on your screenshot - "offset 0,0 size 0,0"

    You need to specify the correct size and offset if you want to take a snapshot of a portion of the screen. Be aware that these values are in device pixels. You'll need to use CanvasDeviceWidth and CanvasDeviceHeight expressions of Platform Info object to convert to device pixels.

    Example:

    | Global number r‎ = 0
    + (no conditions)
    -> System: Set r to PlatformInfo.CanvasDeviceWidth÷ViewportWidth(0)
    -> System: Take snapshot of canvas (PNG, quality 75, offset 100×r, 100×r size 500×r x 300×r)
    
  • Here is a demo. It uses collision polygons in the main tilemap to automatically fill the collision map.

    dropbox.com/s/squgt33uyfuraer/AutoFill_collisionMap.c3p

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can edit collision polygons for each tile if you double-click it in the tilemap bar. However, this may not work for tiles which have walls on opposite sides, since it's not possible to have two polygons.

    I would use another (invisible) tilemap with 64x64 px tiles just for collisions. You can draw walls on it manually or fill it with an event.

    Check out this demo:

    howtoconstructdemos.com/using-an-invisible-tilemap-as-an-obstacle-map-for-pathfinding-capx

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 279 followers

Connect with dop2000

Trophy Case

  • 10-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
  • x14
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

30/44
How to earn trophies