[SOLVED] Pin an object on create them using families

0 favourites
  • 7 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • I'm setting the NormalMaps to every object and for the objects that are already in the layout works perfect using this:

    On Start Layout

    for each (Family) Sprites

    (Family) NormalMaps | Pick nearest to ( Sprites.x , sprites.Y) -> Do (Family) NormalMaps Pin-To-Pin (Family) Sprites (Position&Angle)

    Every Sprite have in their container the NormalMap image. With this i can add all the different sprites/normal that i want and they will be pinned, so if they move, bounce or whatever no problem,

    But how i do the same for sprites that are created previously? i mean during the gameplay .

    I can do it for every sprite individually using this:

    On ObjectX created -> Do ObjectX_NormalMap Pin-To-Pin ObjectX (Position&Angle)

    But how to do using families or with an event that works for all the sprites like the "On Start Layout", to no create a PIN event for every object in the game with normal map that will be create during the gameplay.

  • I don't understand..

    You want to pin objects that don't exist on start of layout?

    You can't perform actions on objects that don't exist..

  • I don't understand..

    You want to pin objects that don't exist on start of layout?

    You can't perform actions on objects that don't exist..

    Then, why works? , This event actions works for me:

    On Start Layout

    for each (Family) Sprites

    (Family) NormalMaps | Pick nearest to ( Sprites.x , sprites.Y) -> Do (Family) NormalMaps Pin-To-Pin (Family) Sprites (Position&Angle)

    I have various objects in the layout that have a container that includes another that is the NormalMap, and when the game runs, with the previous event, every object creates their own NormalMap and gets pinned, so it's already works!. I guess the container action is made before the event "on start layouts" started, but as i said it's already works. Maybe to be more correct i have to change to "On loader layout is complete", but as i said it already works.

    -

    So, for the objects that are already in the layout before the game runs they create another object that is the normal map and gets pinned. They are asteroids that move and rotate and as i said works, try it yourself if not believe me.

    Also i already have working that when a specific/individual object is created get the normal map pinned, but i can't get it working for a family and that's my question.

    I have that every X seconds an asteroid is created. This asteroid have a container that includes the NormalMap image. If i add this event works:

    On ObjectX created -> Do ObjectX_NormalMap Pin-To-Pin ObjectX (Position&Angle)

    So the idea is made that instead of add an event for every object created pinn to their normalMap i want use an event with family or similar to do the same like in the "on start layout" and save add events for every type of the objects created.

  • > I don't understand..

    > You want to pin objects that don't exist on start of layout?

    > You can't perform actions on objects that don't exist..

    >

    Then, why works? , This event actions works for me:

    On Start Layout

    for each (Family) Sprites

    (Family) NormalMaps | Pick nearest to ( Sprites.x , sprites.Y) -> Do (Family) NormalMaps Pin-To-Pin (Family) Sprites (Position&Angle)

    I have various objects in the layout that have a container that includes another that is the NormalMap, and when the game runs, with the previous event, every object creates their own NormalMap and gets pinned, so it's already works!. I guess the container action is made before the event "on start layouts" started, but as i said it's already works. Maybe to be more correct i have to change to "On loader layout is complete", but as i said it already works.

    -

    So, for the objects that are already in the layout before the game runs they create another object that is the normal map and gets pinned. They are asteroids that move and rotate and as i said works, try it yourself if not believe me.

    Also i already have working that when a specific/individual object is created get the normal map pinned, but i can't get it working for a family and that's my question.

    I have that every X seconds an asteroid is created. This asteroid have a container that includes the NormalMap image. If i add this event works:

    On ObjectX created -> Do ObjectX_NormalMap Pin-To-Pin ObjectX (Position&Angle)

    So the idea is made that instead of add an event for every object created pinn to their normalMap i want use an event with family or similar to do the same like in the "on start layout" and save add events for every type of the objects created.

    Your problem here is that the family is not in a container..

    The objects in the family are..

    When an object is created it automatically creates all other objects in the container..

    If you reference the family in the event, it could be any instance of the family, if you reference the object, it will only be the one inside the container..

    The reason it works in the start of layout is because you use pick nearest of the sprite-family and I guess the nearest is the right one..

    When using a container, pick nearest shouldn't be nescessary, but this might work:

    I would use the sprite-family on created, pick nearest enemy and pin, because it's possible that the sprite-family object doesn't exist yet on enemy-family created..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:gc597px3]The reason it works in the start of layout is because you use pick nearest of the sprite-family and I guess the nearest is the right one..

    Correct, without the "pick nearest " not works.

    [quote:gc597px3]I would use the sprite-family on created, pick nearest enemy and pin, because it's possible that the sprite-family object doesn't exist yet on enemy-family created..

    Enemy-Family? or you mean the NormalMap-family?

    I tested various options like "on created & pick nearest > pin" or "On created & Is overlaping > pin" but nothing worked .

    I put a Feature Request here: . An option inside the Containers property to pin-to-pin the desired objects. With this i guess all this events discussed will saved, right?

    I will continue on day more trying to find the solution if not i will create a "NormalMap" group and add there all the pin-to-pin objects individually. Hope the admins ear this and add some feature to save all this in the future.

  • Should be easy, if you set everything up correctly..

    If you are creating family sprites through events, you should use

    on family normalmaps created

    pick family sprites nearest to normalmaps.x,normalmaps.y (or use is overlapping)

    family normalmap pin to family sprites

  • Should be easy, if you set everything up correctly..

    If you are creating family sprites through events, you should use

    on family normalmaps created

    pick family sprites nearest to normalmaps.x,normalmaps.y (or use is overlapping)

    >family normalmap pin to family sprites

    I finaly get working similar like you say, this is the way worked:

    -----------------------------------------------------------------------

    on (Family)NormalMap created

    (Family) NormalMap is overlaping (Family) Sprites

    (Family) Sprites | Pick nearest to (Family)NormalMap.x, (Family)NormalMap.y

    DO > (Family)NormalMap pin to (Family)Sprites

    -----------------------------------------------------------------------

    Without the overlaping condition or the "Pick nearest" not works correctly, booth are needed to work perfect.

    -

    Edit: This is the capx to see

    https://dl.dropboxusercontent.com/u/659 ... fixed.capx

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