Realy OO?

0 favourites
  • 15 posts
  • 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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Ok, thx....and I take this as a "no" <img src="smileys/smiley2.gif" border="0" align="middle" />

  • If it helps you can always conceptualize variables as objects. :)

  • 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 :

    Sprite(2).X

    Maybe being able to have some 'absolute' picking ability with UID would be interesting

    Sprite(4,UID).X

    or even by instance variable

    Sprite(4,myVar).X

    Whe might avoid some foreach. Like this one

    <img src="http://dl.dropbox.com/u/23551572/C2/selectByInstanceVariable.png" border="0" />

  • 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?

  • 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...

    <img src="smileys/smiley18.gif" border="0" align="middle" />

  • Yann

    sprite(0).uid

  • 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.

  • I guess in theory you could make a behavior, sprite(id).behaviorGetpos.x, or like sprite(iid).bullet.speed

  • What is "OO" Open Office? Ocean Orange?

  • Well its really oop, object oriented programing.

    Basically you group things together like classes, etc, so that you can mentally visualize things rather than just looking at it like code.

  • newt

    I'm thinking about a plugin which get all the creating instance, then save the uid - instance reference. So that I can use expression: picker.GetX(uid) to get the x position of instance.

    Because that engine can add a destroy callback in plugin, plugin can remove the instance reference to prevent memory leakage.

    But,... engine has no way to add a create callback. So maybe a behavior is better then a plugin. Behavior can have onCreate and onDestroy.

  • Well, to me, sprite(index), really is the best way to pick in instances.

  • newt

    You may try this [Behavior"> Shell (get inst's expression from uid)

    Sorry, it can only get the expression of instance, not the instance's behavior expression.

    I thought the expression processing of C2 engine can only return "number" or "string".

    sprite(uid).bullet.speed

    first need to return a instance from

    sprite(uid)
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)