Some Questions

0 favourites
  • 8 posts
From the Asset Store
Logo Quiz with 150 prepared logos and answers, automatic question and answer mixing
  • Hey,

    I'm wondering if someone can help me write a function. What I need to do is learn how to move objects that are already drawn on the layout. They would be placed there by the back end user. I think the function I'm writing would help a few people. It's really simple, and might be doable through events, but this one action plugin is cool. Maybe we could add to it for the other users. Likely one around, but what ever.

    Thanks,

    Jeremy.

  • To better suit the question. Is there an array of objects on the layout I can loop through, and access members and functions of those objects...

    for(key in objects)
    {
          if(key == 'name')  
         {
            if objects[key] == 'Cat'
           {
               // do this.
           }
    
       }
    }
    [/code:g49whr2a]
  • Look the source of mutuware Circle Behavior....

  • Hey thanks Gigatron, what's mutuware Circle Behavior? Third party?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm not really seeing what I need in there. I'm looking for a way to loop through all the objects in a layout. So that I can run a specific operation on the object with a certain name.

  • I think I found something that might be useful to me.I need some clarification.

    What I see is this:

    runtime.types_by_index[]

    An array of all the object types in the project.

    What would be in that array? Would I be able to access objects from there?

    Also the page says this:

    The runtime object represents a single instance of a user's project running in the browser. It is usually accessed via this.runtime from an object instance. Remember only documented properties and methods should be used.

    What does it mean. The run-time is accessed form an object instance? Does this mean an instance I would have to pass as a param? If so, that kind of defeats the purpose of what I'm trying to do.

  • The way to do this is to use an action with an object parameter, and only modify the instances passed to the action. That gives the user control over which objects to modify, as changing every instance in the whole layout (text, UI elements, etc) is obviously not useful.

    An object parameter passes the object type which has an 'instances' array. For each instance you can directly assign its x and y properties, and then you must call set_bbox_changed() on the instance after any changes.

  • This is very confusing. Passing an object doesn't seem to help me in my case. I really need to access every object in a layout. I couldn't find a way in Construct to do something to an object by name. I could store text values in an array, as names of items, which are actually sprite names

    array[0] = 'hat'

    array[1] = 'boots'

    You can loop through an array with a foreach... but there doesn't seem to be a simple way to move an object name.

    I figured I could make a simple plugin for my game which created an action that moved an element to X,Y simply based on sprites name.

    Also I would have a corresponding expression... Then I could use the foreach to loop through the elements of the array in my layout then for each value call the expression move(element, 12, 12), say.. that would put the item of that element at 12 12. I could call the expression for each value in my array and move a whole array of items where ever I wanted.

    I'm not that good with this kind of stuff, so figured if I could loop through each object, that would do it.

    Other wise I was stuck with a ton of events, acting as a pseudo switch.

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