anyone discover any bugs using On Function calls with create

0 favourites
  • 7 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • my question is are On Function calls running the normal built in javascript for each loops like written in the blog for performance fixes? i was told every time you have stuff like this

    On function initCreate

    Repeat 1 times

    Object1 Boolone is true

    Object1 BoolTwo is false

    create this and do stuff with it

    it would run automatic for each loops from built in javascript object scoping.. it doesnt seem to be doing it. or atleast not with create events I had to add a For Each Object1 to the times it repeats for it to work

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Objects are being created on the next tick, if I'm correct. So you got to use On created instead.

  • Functions are only run when you call them, and when they are they are run as if they were inserted in place of the call minus any picking.

    Creating objects does create the object right there and picks it, but you can't pick it as normal elsewhere until the next toplevel event. Here's some info on that to help explain what occurs:

  • strange it did as you said because I can make it a command but not loop through it at the start without for each

  • JavaScript doesn't have a built-in init() function, that is, it's not a part of the language. But it's not uncommon (in a lot of languages) for individual programmers to create their own init() function for initialisation stuff.

    A particular init() function may be used to initialise the whole webpage, in which case it would probably be called from document.ready or onload processing, or it may be to initialise a particular type of object, or...well, you name it.

    What any given init() does specifically is really up to whatever the person who wrote it needed it to do. Some types of code don't need any initialisation.

  • Ok, I'm lost now.

    All this talk about JavaScript is irrelevant since events aren't JavaScript.

    Re-reading the op is the question why only one object is created with those events?

    The system actions are only done once so you would have to add a for each to create an object for each of another one that meets that condition. Now if you used a sprite action instead it would automatically be done for all the picked instances of that sprite.

  • apparently they are

    [quote:166hi2qv]Unnecessary 'For-each' loops

    The System For-each looping condition is useful in lots of circumstances, but it is often used where it makes no difference. Going back to How Events Work, conditions are tested for each instance, and then actions are run for each instance that met the event's conditions. As that sentence suggests, the Construct 2 engine already has built-in for-each loops to help events run as you expect. For example, consider the following event:

    An ordinary event in Construct 2

    Construct 2 already runs the event like this: for each monster that is hunting, set the angle towards the player's position. However we often see events that look like this:

    An example of a redundant for each loop

    In this case the use of the system For each loop is redundant. It shows a misunderstanding of how Construct 2 events already work. It does not change the meaning of the event at all - the engine was already doing that. Again, there are two disadvantages to this kind of event: mainly that it is confusing to include events that have no effect, but also performance is a bigger concern in this case. The engine's own for-each loop happens directly at the javascript level, and is fast; for-each loops happening at the event level involve the overhead of the event engine, which while we've worked hard to optimise, should be avoided if unnecessary.


    maybe im wrong but this is what Ashley wrote I assumed it meant the events run using javascript or something.

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