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
44
S
23
G
13
Posts: 723
Reputation: 14,925

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
395
S
232
G
88
Posts: 24,371
Reputation: 193,762

Post » Fri Dec 30, 2011 11:56 am

Ok, thx....and I take this as a "no"
B
44
S
23
G
13
Posts: 723
Reputation: 14,925

Post » Fri Dec 30, 2011 4:37 pm

If it helps you can always conceptualize variables as objects. :)
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

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
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

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
106
S
21
G
14
Posts: 549
Reputation: 20,980

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
44
S
23
G
13
Posts: 723
Reputation: 14,925

Post » Fri Dec 30, 2011 6:42 pm

@yann

sprite(0).uid
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

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
66
S
22
G
14
Posts: 1,484
Reputation: 16,511

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 ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Next

Return to Construct 2 General

Who is online

Users browsing this forum: lukewasthefish and 7 guests