Realy OO?

Discussion and feedback on Construct 2

Post » Fri Dec 30, 2011 8:58 am

In some other post, I read, that C2 is OO. If so, are there plans to extend variables and arrays to hold "objects" as well as text, integers and booleans?
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Dec 30, 2011 11:53 am

This comes up a lot, but you can hold an object in a variable by storing its UID, and use the 'Pick by UID' condition to pick it again later.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Fri Dec 30, 2011 11:56 am

Ok, thx....and I take this as a "no"
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Dec 30, 2011 4:37 pm

If it helps you can always conceptualize variables as objects. :)
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Dec 30, 2011 5:52 pm

maybe it could be intersting to have th ability to pick by uid directly in expression.

we can already pick by index of selected objects like :[code]Sprite(2).X[/code]
Maybe being able to have some 'absolute' picking ability with UID would be interesting
[code]Sprite(4,UID).X[/code]
or even by instance variable
[code]Sprite(4,myVar).X[/code]
Whe might avoid some foreach. Like this one

Yann2011-12-30 17:54:59
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Fri Dec 30, 2011 6:17 pm

Well, C2 really is object oriented, surely, in the accepted sense that its objects have both behaviour and state.

@weishaupt, I think you're meaning something else when you ask for variables to hold objects. When Ashley points out that you can hold an object in a variable by storing its UID, does that not give you what you want?
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Fri Dec 30, 2011 6:19 pm

Sure, I can live with storing a reference to an object instead of storing the whole object. Its just a little more code ans probably not so straight forward for neebies...
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Fri Dec 30, 2011 6:42 pm

@yann

sprite(0).uid
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Dec 30, 2011 6:55 pm

That's not the point newt (:
I don't want the uid I want the X of the sprite of uid 4 directly in expresion.
that's why I wrote Sprite(4,uid).X

I was thinking about that 'cause you could get some tricky math between instances of the same object type without having to complexify stuff with some foreach to pick things.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sat Dec 31, 2011 3:14 am

I guess in theory you could make a behavior, sprite(id).behaviorGetpos.x, or like sprite(iid).bullet.speed
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 6 guests