Retrieving properties of other object? (converting old C2 runtime to C3)

0 favourites
  • 2 posts
From the Asset Store
A cool way for kids to write and practice English Alphabets
  • Hi

    I'm trying to convert some custom C2 behaviours to C3 runtime and I'm struggling to work out how to pass values between instances.

    In the old C2 runtime I would be able to reference properties of another object by using object.extra["propertyName"] to check a property of another object.

    Is there a way to do this in the C3 runtime? I can obtain the 'object' part and have called GetSdkInstance and GetRuntime but I can't seem to delve any deeper into the properties or call any functions.

    I understand this is much more sustainable to do in the event sheet, but I'd REALLY rather not rewrite the whole game if at all possible.

    I'm not releasing the game, it's purely internal only and for the enjoyment of a small group of friends, so even if it's an unsupported function I'd be happy.

    Cheers

    CB

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Well, JavaScript lets you attach extra properties to any object, so the fact that a property named extra is no longer in the C3 runtime shouldn't stop you - you can just put extra properties directly on the object (so long as the names are unique). However I would advise to use a WeakMap instead, as a better and more modern way of tracking custom state with other objects in JavaScript. You can use the object you want to add state to as a key, and an object with all your custom properties as a value, and because it's a weak map your custom state will get garbage collected at the same time as the other object and so not leak memory.

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