How long does a 'Pick' sprite last?

0 favourites
  • 9 posts
From the Asset Store
Full game Construct 2 and Construct 3 to post on Google Play
  • I have a growing project, and I'm not that used to picking sprites. I have found that almost any time I want to reference or check a sprites variables I have to precede it with a pick.

    I do have the sprites in a Family, and generally I am using family instance variables.

    So, as an example, You have 3 players, and each player has 3 tokens (with the option of more).

    Each player moves their 3 (or more) tokens one at a time, then they can buy more tokens and the next turn they can move them too (Eg: 4 tokens next time).

    Each token belongs in the 'Token' family, and has 2 family instance variables. 'famPlayerNum', and 'famTokenNum'.

    I have all of this working, but I seem to have a lot of Pick statements, am I supposed to is the 'simple' question or is there a better way.

    Here is a sample C3 project link.

    drive.google.com/file/d/1AFAACx26ITVMBtiR4eAQ0Atf3l3wq0PH/view

    Tagged:

  • Picking is per tick.

    That's the basis of the engine. Every tick it asks should it do this or not.

    I would suggest using less functions, as they break picking. Use global variables, and instance variables instead.

  • If its a new Picking you need to start from scratch always Comparing Variables etc.... But if the Picking didn't change you could save the UID of the Sprite so you can keep Picking it whenever you need directly

    Example:

    Have a look at on "Key Down Pressed" I Pick directly the Player I need By UID without the Need to loop again throughout all the Players to check who is matching the condition as opposite than we do on the Function "Pick_Player"

    Also, you don't need that many Functions as Newt mentioned

    https://www.dropbox.com/s/3jjshxd3bjkq98q/Picking.capx?dl=0

  • Thanks folks for the good answers. I tend to arbitrarily lean towards functions as it cuts down on repetitive code in larger projects, but I can also (through experience) see that it appears to work a lot better, and easier to read if I just list it all out in one spot :)

  • Functions like this are good in some scenarios if you pass the family UID through the function so it can always be recognised but I agree that functions are of no use with this turn logic, better to just use global variables.

  • I really think that C3 dev team should consider putting some serious thought and effort into improving functions. What we have now in C3 functions is a reasonable "MVP", but definitely not great.

    An example improvement...

    A function refactor that would allow us to complete the prior "tick" on each function call. If you don't want to risk breaking existing functions with a refactor, give us another function call (or a function call param?) that completes the prior tick when called.

  • The deal with functions not keeping picks is an engine thing, not a function thing.

    Like suppose you had an event that destroyed the object you just created in the same tick?

    That would be pointless, and hard for the engine to factor in, uid's counts, etc.

    Also this:

    twitter.com/AshleyGullen/status/1105538818093080578

    Although I have no idea what this will bring to the subject.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok that's some interesting functions improvements. I look forward to it. Thanks for the link :-)

  • For now I'm simply adding a "wait 0 seconds" at the very start of my functions to finish the current tick. So far this is working but I have more testing to do.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)