[SOLVED] Pin an object on create them using families

Get help using Construct 2

Post » Sat Dec 19, 2015 3:09 pm

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.
Last edited by matriax on Sat Dec 19, 2015 9:34 pm, edited 2 times in total.
B
23
S
10
G
3
Posts: 534
Reputation: 4,418

Post » Sat Dec 19, 2015 4:10 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Dec 19, 2015 5:21 pm

LittleStain wrote: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.
B
23
S
10
G
3
Posts: 534
Reputation: 4,418

Post » Sat Dec 19, 2015 5:44 pm

matriax wrote:
LittleStain wrote: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..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Dec 19, 2015 7:37 pm

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.

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: feature-request-containers-with-pin-to-pin-option_t165543 . 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.
B
23
S
10
G
3
Posts: 534
Reputation: 4,418

Post » Sat Dec 19, 2015 7:54 pm

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 told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Sat Dec 19, 2015 9:24 pm

LittleStain wrote: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
B
23
S
10
G
3
Posts: 534
Reputation: 4,418


Return to How do I....?

Who is online

Users browsing this forum: repkino and 1 guest