Testing if a function exists ?

Discussion and feedback on Construct 2

Post » Fri Jan 16, 2015 2:16 pm

@Aphrodite

It is true that functions cannot be referenced from an event sheet that does not include the relevant sheet containing the function itself. However, event sheets cannot be included conditionally.

You will notice that when you include an event sheet, the INCLUDE statement is always placed at the top of the event sheet.

A conditional include would look something like this:
IF X == TRUE THEN INCLUDE EVENTSHEET1
ELSE INCLUDE EVENTSHEET2

All event sheets (which are represented as XML) are converted to Javascript and bundled in the final exported code during the build process. When a project is previewed/exported, Construct knows exactly what functions are available at a per-event sheet level.

@Refeuh

You're right about that. As a software engineer by trade, Construct is a way for me to wind-down at the end of the day. It's definitely my favorite RAD tool for games.
B
31
S
7
G
8
Posts: 232
Reputation: 6,244

Post » Fri Jan 16, 2015 2:37 pm

cacotigon wrote:@Aphrodite

It is true that functions cannot be referenced from an event sheet that does not include the relevant sheet containing the function itself. However, event sheets cannot be included conditionally.

You will notice that when you include an event sheet, the INCLUDE statement is always placed at the top of the event sheet.

A conditional include would look something like this:
IF X == TRUE THEN INCLUDE EVENTSHEET1
ELSE INCLUDE EVENTSHEET2

All event sheets (which are represented as XML) are converted to Javascript and bundled in the final exported code during the build process. When a project is previewed/exported, Construct knows exactly what functions are available at a per-event sheet level.

@Refeuh

You're right about that. As a software engineer by trade, Construct is a way for me to wind-down at the end of the day. It's definitely my favorite RAD tool for games.


an include can be a subevent, thus conditionnal, C2 may place the include at the top, but you can move it freely.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
52
S
22
G
18
Posts: 2,122
Reputation: 17,093

Post » Fri Jan 16, 2015 3:43 pm

Aphrodite wrote:
cacotigon wrote:@Aphrodite

It is true that functions cannot be referenced from an event sheet that does not include the relevant sheet containing the function itself. However, event sheets cannot be included conditionally.

You will notice that when you include an event sheet, the INCLUDE statement is always placed at the top of the event sheet.

A conditional include would look something like this:
IF X == TRUE THEN INCLUDE EVENTSHEET1
ELSE INCLUDE EVENTSHEET2

All event sheets (which are represented as XML) are converted to Javascript and bundled in the final exported code during the build process. When a project is previewed/exported, Construct knows exactly what functions are available at a per-event sheet level.

@Refeuh

You're right about that. As a software engineer by trade, Construct is a way for me to wind-down at the end of the day. It's definitely my favorite RAD tool for games.


an include can be a subevent, thus conditionnal, C2 may place the include at the top, but you can move it freely.



@Aphrodite It doesn't matter. The include statements are not processed at a run-time conditional level. All event sheets are bundled into the final JS code of a project irrespective of whether they are explicitly included. So you can move the INCLUDE blocks around wherever you want, but it makes no difference.

Here's a capx demonstrating it and the associated code.

Image

Capx
https://dl.dropboxusercontent.com/u/12667027/IncludeTest/includetest.capx
B
31
S
7
G
8
Posts: 232
Reputation: 6,244

Post » Sat Jan 17, 2015 9:39 am

Refeuh wrote:Btw I find it amusing that we have that many users well-versed in the art of programming :) C2 claims "no programming required" (which I personally find a bit misleading, the logic of event sheets is similar to light/gameplay-programming), yet it attracts people with a technical background ! Mostly for the productivity when creating small applications or testing prototypes, I guess.


Yes somehow after looking at many game dev tools, I knew immediately that C2 was for me. Don't ask me how, it was kind of weird. I also find a knowledge of concurrent programming concepts, not to mention traditional coding in general, helps a lot (despite having to unlearn a lot of stuff). I think those without prior coding experience perhaps miss out on some aspects, but it's not really missing out because each user finds what they need I guess.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests