is there a way to make pure object that has properties?

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • actually I want to create an object that has properties and is pushed into an array if possible.

    then I tried it this way:

    create a sprite object and add some instance variables, then try to push this object using array> push: here I can't push the sprite object directly? then I tried entering the instance variable, it worked, the problem I had was that when I pushed it, it wasn't wrapped into one object, which in the end would be difficult for me,

    any help is greatly appreciated, thanks

    description of each object and property in the array

    Tagged:

  • Arrays can store numbers or text, they can't store objects.

    If you want to store a bunch of properties in order to recreate the object in the future, there are two ways to do this:

    1. Use a 2D array and save each property in a separate cell. For example, set array height to 4 and save Player.X, Player.Y, Player.health and Player.armor

    2. Save Object.AsJSON string. Then to restore an object with all properties use "Sprite load from JSON"

  • Thank You,

    No. 1. I tried it, and as far as I know, Json is a static format and its properties cannot be pushed like objects

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Object.AsJSON returns a string of text. You can store it in an array as any other text.

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