Here is a way to dynamically create instances

Get help using Construct 2

Post » Sat Dec 28, 2013 7:18 am

It's all probably very usefull, although it seems overcomplicated.

Just a small question though.
You state Construct2 has asynchronous callback, or something like that, but in a creation event when you use subevents automatically the just created instance is referenced, wouldn't that be called synchronous?

I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sun Dec 29, 2013 4:46 am

My understanding of how Construct2 creates objects (async vs sync) is largely based on this post (http://www.scirra.com/forum/wait-next-tick_topic65424.html).

You two bringing up the question (and after everything I have learn in the past few days) I decided to create a new test capx which seems to show that I can call a general purpose function that accepts a string and returns a UID and it can be immediately picked by a Family. So I am not sure what it is they were talking about in that post above.

Obviously this new capx is just a quick test I did so I am going to start using this new method that is SYNCHRONOUS and see if everything works correctly with it. If so I will change the tutorial (and this post) to not claim that objects are created asynchronously. Async method calls with callbacks (which is commonly used in JavaScript and other languages) is still useful so I will leave the tutorial either way and modify it to show the Sync method as well.


ggibson12013-12-29 05:05:21
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Sun Dec 29, 2013 7:32 am

@LittleStain

I just converted my app (I wouldn't call it a game yet... more of a test to see how far I can push the Construct2 engine) so now I have a slicker version of the New function that does both Sync and Async and it all seems to be working well.

I wanted to point out one example of where in JavaScript in the past I have taken advantage of Async callbacks. I am a principal engineer at a large Internet company that has nothing to do with gaming so my experience is with a data analytics app, but still I did some JavaScript coding on it.

When you make remote calls back to a server such as with JQuery $.ajax calls they are actually async calls. The browser completes that call on a background thread and then does an async callback to a JavaScript function you provide when the Internet server has responded to your request.

You can certainly mix sync and async methods. However a growing trend in software engineering is building most functionality to be async. This allows future advancement like distributing computing across cores (with threads) or across machines. For example look at the technology from Microsoft called Rx (Reactive Extensions) which has a JavaScript version... Netflix made a Java version to run the code that puts together the lists of suggested videos they show you in their UI...

ggibson12013-12-29 07:36:02
B
21
S
5
Posts: 196
Reputation: 1,974

Post » Sun Dec 29, 2013 8:27 am

First let me say like many others here, I don't come from a programming background. Using Construct2 is the first time (apart from old fashioned html-website building) I tried to do anything with programming.

Construct2, has some asynchronous callbacks, the best examples I can think of now are Ajax and pathfinding. To make it easier for non-programmers like me, these have the "on data recieved" / "on path found" events attached to them.

The topic you linked to was started by Yann and he/she is a very capable programmer, so I'm sure the things described in it make sense, although it confuses me also.

I will have another look at your capx and tutorial and try to understand what kind of benefits there would be for me personally to create the events your way.
It's always interesting to see how someone with a different background tries to tackle issues, it always learns me a lot.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Previous

Return to How do I....?

Who is online

Users browsing this forum: KTML5 and 27 guests