Object Creation and On Layout Start

  • I have created two functions (thank you for making functions possible!)

    initDeck() and shuffleDeck()

    in the event "On Layout Start", I call initDeck() which creates the physical cards on screen. This works no problem.

    After that is called, the shuffleDeck() function is called (still within the On Layout Start event).

    shuffleDeck is not able to pick created objects for events (ie: DeckOfCards) and therefore does not shuffle the cards.

    My shuffle function works as expected, if I place the call within a mouse event (ie: middle button clicked), but not if I call it within "On Layout Start" right after the objects have been created.

  • Both functions are running on the same tick, that's why. I believe if you add a "wait 0.01 seconds" between the two function calls you will solve the problem

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There was somekind of change a number of iterations ago that newly created objects can't be manipulated in the same tick. I'm not sure how entirely true this is as I have managed to with immediately created objects, but it should be considered when doing design work.

  • jayderyu: The change you're talking about is that the instance is not actually created before the next event of the same level.

    You can apply actions to a newly created instance, right after a "Create" action, but you can't do picking of that instance before the next event.

    That's what happens with the second function.

  • Well that nicely explains it :)

  • Thanks everyone...that explains it and gave me a good solution that works. I appreciate a community that is friendly and helpful. Eventually I will have a better understanding of this tool and can return the favor to new users

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