kellehk's Forum Posts

  • Wow. Thank you SO much. You really helped me out! I'm super new to construct 2 so I'm still getting the hang of which events are the best to use for what.

    I really appreciate it, thanks!

  • Hey everyone.

    Here's my capx:

    I'm trying to make a connect the dots game using a hex grid.

    Long story short, I have a grid of "cell" objects with instance variable "IsEmpty"

    The grid is filled with colored "Dots" which get destroyed when the player connects dots of similar colors.

    When a dot is destroyed, its associated cell is set to empty.

    I then have a function that selects the cell above, takes the dot inhabiting it, and moves it down to the empty space.

    (Note: I want the dots to move in a zigzag like pattern down, so in a 6x6 hex grid, for example, a dot from the 6th hexagon will fall into the 12th hexagon; this explains my logic in selecting the dot)

    I have a special handler for the top row, where empty spaces will be filled by "spawn" points above.

    I would like this to keep repeating until the grid is full, but for some reason the dots stop moving even though there are still empty spaces on the grid.

    I think I'm having trouble with checking the empty cells every tick. Not really sure what event to use. I tried "For each empty cell," and "pick cell where cell is empty," I even used a number variable to try to count the number of empty spaces, but that didn't seem to work.

  • Okay. I'm getting really frustrated now, because it SHOULD work but it's not.

    I added a "NumEmpty" Variable that gets added to every time a dot is destroyed.

    The system checks if NumEmpty > 0 every tick and is supposed to call the FillEmpty() function as long as there are empty cells.

    However, when I run it and destroy some Dots, they only move once. and Spawn Dot isn't even called.

    Here's the updated capx:

  • UPDATE:

    I got them to move, but I'm now running into an issue where the last dots to move down move a cell too far and intersect with other dots.

    Here's the capx:

  • Ok, I think I fixed it. Or at least made it slightly less broken <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    (link removed)

    I changed the way you select dots that should be moved (nearest dot which is above the cell) and I put the entire "For each cell" loop into a function, because I think it should not be executed on each tick.

    I call this function after a line has been completed or after all dots have stopped moving.

    It still uses pathfinding just to move dots, and not for its true purpose <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    You should probably replace it with MoveTo behavior or Custom Movement or something similar.

    Edit: Fixed a few more things, here is a new link:

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

    Thanks. Unfortunately I can't open your file because I only have version 244. I assume 246 is a paid version?

  • I don't really think I need obstacles or solids, I just want to move the dot from one location to another.

  • Your link is broken.

    Try posting it without the "https://"

    Fixed. Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • UPDATE:

    I got them to move, but I'm now running into an issue where the last dots to move down move a cell too far and intersect with other dots.

    Here's the capx:

    ______________________________________________________________________________________________________________________________________________________________

    Hey everyone. I'm new to construct 2 and I'm trying to work out an issue with path finding.

    Right now I have a hex grid filled with "Cell" objects, each with an instance variable "Index" that's a number between 1 and 36 (It's a 6x6 grid).

    The dimension of the grid is denoted by "DIMENSION" global variable (in this case, 6)

    Cells also have an "IsEmpty" Boolean variable.

    Initially the grid is filled with "Dot" objects. Throughout the game the Dots are destroyed, emptying their inhabited cell (Setting IsEmpty to true).

    The distance between each dot on the grid is denoted by a variable "DistBetweenDots"

    To handle this I have the following event block:

    The nearest dot is selected, and we compare its distance to the current cell.

    If there is no dot in the current cell, the distance to the nearest dot will be greater than DistBetweenDots/2.

    Then, for all empty cells (excluding cells in the top row where Index > DIMENSION, because in that case new dots will be spawned)

    I want to move a Dot from above into the empty cell. The dot to be moved is in the cell whose cell index is (empty cell's index - DIMENSION)

    For this, I create a function MoveDot, with parameters (Dot's current cell index, target cell x, target cell y):

    As seen above, I have placed debug statements to see where it goes wrong.

    I am able to get to the point where a path is found. But once I call On pathfinding path found:

    It does not execute. I know this because debug2 does not get set to "setting along path"

    The logic seems correct. I'm not sure why the On "Pathfinding path found" Event is not triggering. Is the dot unable to find a path? Why would that be?

    Here's the capx:

    Thanks for any advice.

  • Thanks. Unfortunately I only have the free version so I can't use families.

    But I will use your previous advice

  • Sure thing. Here it is:

    dropbox.com/s/u0ev0icxdmcvu2w/Dots.capx

  • Have you tried running your project in Debug Mode (Ctrl-F4)?

    You'll be able to see what's going on - if the Line sprite gets created, which animation/frame playing and so on.

    If this doesn't help, try adding debug output. This could be a text objects somewhere on your layout. Make it big, set text wrapping=Character. Use Text->Append text to print some debug information to it. For example:

    MyDebug -> Append-> "ActiveDots:" & NumActiveDots

    or

    MyDebug -> Append-> "Line:" & Line.UID & " picked:" & Line.PickedCount

    Or you can use Browser->Log action for this.

    Yeah, I probably should have mentioned, I added a debug statement to the second touch event, and it triggered on the first click of a Dot.

    Maybe it's instantaneously registering two touches?

  • I essentially did what the video said, but since the concept of what I'm trying to make is a bit different, I had to adjust it to fit my needs.

    Here is the event sheet as it is right now:

  • Hi guys. Super new to construct 2.

    Had a question on touch controls and conditions.

    Right now I have a bunch of "Dot" objects Laid out on a grid.

    The distance between each dot is about 160 pixels, and there are 5 different possible Dot colors (Same object, different animation frame).

    When a Dot is touched, a line of the same color spawns at the Dot's position, and its width adjusts to the position of the cursor.

    I want to make it so that when you drag the line to an adjacent Dot (Within 160px) of the same color, the current line stays in place and a new line starts.

    I roughly followed This video: youtube.com/watch to do the line mechanic.

    I have a global variable keeping track of the number of active (selected) dots.

    I have two different On touched events:

    One for when the first dot is selected:

    And another for when more than one dot has been selected:

    Under my assumption, whenever a Dot is touched, the system will pick the appropriate touch event depending on the NumActiveDots condition.

    However this doesn't seem to be the case.

    I managed to start the first line when clicking the first dot, but after that no other lines spawn.

    Sorry if I explained things in a complicated way.

    EDIT: Here's the capx: dropbox.com/s/u0ev0icxdmcvu2w/Dots.capx

  • The condition "If dist <= 32" must be OUTSIDE the function. Right now it just checks the dist at the moment the objects are spawned and, obviously, it's bigger than 32 at that moment.

    Something like this: dropbox.com/s/kg0jiaacdq90i ... .capx?dl=0

    Hope this helps. Cheers!

    Thanks! This clears things up a lot.

  • I don't get where the "function" usefulness comes from ? Instead of using a function trigger to start your event, just use the "on object created" trigger, what do you think ?

    In order to have a function triggered event to run, you need to have something trigger this function in the first place. I'm almost certain you know that and probably have another event somewhere that calls your "SpawnDot" function, but it seems over complicated to me, as seen.

    Also, in order for your object to move, you need to have another event that goes like this :

    Dot => on path found => move along path

    at the moment, your object calculates the path to point A to point B, but is not told to move along it properly.

    Thanks. And yeah, I call the function in another part of the event list that I didn't show because it wasn't relevant. I'm just used to organizing things into functions so that's why I did that.

    A lot of my confusion comes from being new to the engine. I'll try out your advice. Thanks again!