Native array methods

For developers using the Construct 2 Javascript SDK

Post » Tue Feb 03, 2015 11:45 am

Hello there! :)
I'm using SC2 for several years but it's first time I decide to make my own plugin.
Well, to improve existing one a little..

I have experience to work with different programming languages (C++, Delphi, Pascal and some others) and my question is not about how to make some things in JS.
But I can't find some information about where some methods (functions, properties etc.) came from.

This is a particular example.
Plugin: Array
File: runtime.js
Where can I find description of this things: cx, cy, cz, forX, forY, forZ, arr, forDepth and some others? I've tried to search it in *.js files in html5 folder but no succeeded.
I see that we can write this.cx = this.properties[0]; and this will be a Width of our Array.
And for example var a = this.arr; what is arr? It seems to be smth. like a link to our array but where did we found such description and others?
Well, another example, what means this.forX = []; or this.forDepth = -1;

I hope you understand what I want to know. Maybe I just can't see things under my nose :|
B
8
S
1
Posts: 72
Reputation: 606

Post » Tue Feb 03, 2015 1:27 pm

Those variables are all entirely defined and used within that single file. If you don't know Javascript, it might be better to ask on a site like StackOverflow.com.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Tue Feb 03, 2015 2:34 pm

Well, thank you for your time, Ashley.
For now I can see that I just mix up in my head declaring and assignment.
Maybe I need to learn JS more, because I can't understand why we wrote for the first time
this.cx = this.properties[0]
instead of
var this.cx = this.properties[0]
I thought, that it is an assignment, just not declaration. It seems, that I'm not right..
B
8
S
1
Posts: 72
Reputation: 606

Post » Tue Feb 03, 2015 3:16 pm

That is normal Javascript style. In constructors, member variables are initialised simply by assigning a value to this.something.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Tue Feb 03, 2015 6:46 pm

This is already an object like var a = {}, so values can be assigned to a.something freely.
B
79
S
13
G
8
Posts: 1,976
Reputation: 9,947


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests