[suggestion] for variable

Discussion and feedback on Construct 2

Post » Fri Dec 21, 2012 12:43 am

After working with C2 for a few months I find that I would love a default variable feature.

As it is now when you create a new variable either as global/local/object you can only set a basic value(text/number/boolean). The suggestion is to allow for either reference to another variable or even a piece of code.

I am not saying this a mandatory feature or must have, just an convience to reduce event's. As an example theory of use which I was thinking today.

var highPoint = (layoutWidth / 2)

in the moon bullet behaviour
Moon.Bullet.gravity: (Moon.x < highPoint ? -20 : 20)

the purpose of this is that even without doing an event the moon will rise when it's left of the layoutwidth and descend when it's on the right. This is just a simple theory sample. But it could lead to some more embeded results for variable.


alternatively instead of js code, it could be linked to a function

Moon.Bullet.gravity: @celestialGravity
Sun.Bullet.gravity: @celestialGravity

onFunction("celestialGavity")
set return value = (Moon.x < highPoint ? -20 : 20)





B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri Dec 21, 2012 2:51 am

So what you're asking for is the ability to use expressions in the objects parameters, rather than having to assign them at run time?
newt2012-12-21 03:58:32
Image Image
B
161
S
48
G
90
Posts: 7,350
Reputation: 66,755

Post » Fri Dec 21, 2012 3:44 am

Love the suggestion! You can think of it as a virtual variable or a really simple getter.
B
35
S
8
G
8
Posts: 532
Reputation: 6,868

Post » Fri Dec 21, 2012 5:09 am

[QUOTE=newt] So what you're asking for is the ability to use expressions in the objects parameters, rather than having to assign them at run time?
[/QUOTE]

Yes that sums it up. In some cases it would only be applied naturally on creation of object or start of layout. Other times like gravity on platform or bullets and so on it would be applied per render.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Fri Dec 21, 2012 1:38 pm

This has already been on our todo list a while... hopefully we'll get round to it eventually.
Scirra Founder
B
359
S
214
G
72
Posts: 22,951
Reputation: 178,578

Post » Fri Dec 21, 2012 5:15 pm

oh well. that's just awesome :)
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 13 guests