How create obj by name?

0 favourites
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Yes I need this feature too; I ended up with a long "switch" (as in the programming structure) that I keep adding to whenever I need a new object type created by the "factory".

    Is it possible to create by "class ID" or something?

    I think SC2 should do the same

  • Ashley

    I would like to use a large layout with many instances in an Android project. To cut down the object count I am destroying the objects and referencing them in an array at the start of the layout and calling them when necessary.

    The animation name method would be a reasonable way of creating objects by name. However I will be using a lot of different pseudo objects (i.e animations). This is difficult from a planning point of view in the layout editor.

    In the editor you have an "initial frame" setting. Would it be possible to have an "initial animation" setting and also display the selected animation in the C2 editor?

  • I agree with the 'initial animation' setting. At the moment the only way t odo this is with han instance variable and an event.

  • having a "create object with var name" would greatly benefit eventing, it would simplify events,+ be more dynamic, like been said, using animations or frames is not always an option or the preferred choice, i really hope something like this gets implemented

  • I really cannot think of a place where 'create object by name' would be useful enough to warrant these security flaws. We have aniamtions and frames - shouldn't this be enough?

  • im really questioning the likeness someone will reverse engineer, this would be generally hard to do and a good programmer can probably recreate the behavior faster on its own, but keeping this into account i suggested making an object by a variable "name" or something else

    using frames is a workaround, at the end of the day you want things collide with objects, with there own set of animations and frames

    the whole system is setup around using objects, why make things hard and make it so that whenever you want to reference this object you need to include "is on this frame"

    an example would be an editor, where you want the least amount of duplicated objects (for maintenance), you simple make a menu out of the objects, when clicked on the object it creates that object by getting the var name, this with one action for all objects!

    not 20 or more create actions, creating that specific object + every object that gets introduced

  • This thread is a few months old. Since then a really good workaround has come about: just make a family, add all your objects to it, and add a family instance variable called "name" with text type. Type in all the object names to the instance variable, then you can just use the instance variable to compare the object's name, pick by object name, etc.

  • yesterday i created an example exactly as you describe

    tread

    but the only thing missing, is that you cant create the object based on this "name" , if this would be possible, you would only need one event and a compare function, to create all objects, there would also be less need for replacing objects in eventsheet

  • Ashley

    My following example is a rough prototype for having large layouts on an Android device. The objects are all placed on the layout, placed in an array at the start of layout and deleted and then recalled as you you scroll across the layout. However I also have the same creating objects by name issue as I want a large amount of different object types i.e 100s

    dl.dropbox.com/u/41218343/LargeLayoutsEXP5.capx

    If I could set each instances's animation in the layout editor and also see the chosen animation I could see and plan a layout without using a massive amount of object types and without repeating the code for each object type because it could be done with variables.

    It would be like having an object working as if it were a family with limited features and would be really useful, especially for a rich background.

    Do you think it would be possible to add a feature to be able to select an initial animation in the editor and to be able to see it?

  • vtrix

    Perfect example! Thanks, that helped me a tonne.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Creating objects of the certain type on run time is really painful right now: you have to make a particular case for each object type. Please do something with it.

    One possible solution could be to be able to pass "object type" to a variable and than use variable to create objects.

  • looked at the example... wow, ok, it does work but what a mess. All that so we can avoid the possibility of someone reverse engineering our project!? Man, there just ought to be a better way. I just want a way "create object by name"... from all my searching on the forums and tutorials I guess it's just not possible.

    Thanks for taking the time to post an example solution anyway.

  • Thanks a ton Kyatric for the changing animation instead of object. I had been trying to think of a way to do something for a while and never thought of that...

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