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
21
G
13
Posts: 723
Reputation: 14,740

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
382
S
223
G
85
Posts: 23,987
Reputation: 189,521

Post » Fri Dec 30, 2011 11:56 am

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

Post » Fri Dec 30, 2011 4:37 pm

If it helps you can always conceptualize variables as objects. :)
Image ImageImage
B
165
S
49
G
147
Posts: 8,041
Reputation: 96,574

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
64
S
22
G
14
Posts: 1,482
Reputation: 16,457

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
21
G
13
Posts: 549
Reputation: 20,680

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
21
G
13
Posts: 723
Reputation: 14,740

Post » Fri Dec 30, 2011 6:42 pm

@yann

sprite(0).uid
Image ImageImage
B
165
S
49
G
147
Posts: 8,041
Reputation: 96,574

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
64
S
22
G
14
Posts: 1,482
Reputation: 16,457

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
165
S
49
G
147
Posts: 8,041
Reputation: 96,574

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 4 guests