Problem with "attachtonewparent"

Game development with Board Game Arena Studio
Post Reply
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Problem with "attachtonewparent"

Post by Badguizmo »

Hello.

I am facing a problem when using "attachtonewparent".
In the Studio doc it is specified that "With this method, you change the HTML parent of "mobile_obj" element. "target_obj" is the new parent of this element. The beauty of attachToNewParent is that the mobile_obj element DOES NOT MOVE during this process."
But when using it my object in moving, apparenl=tly for 7px (10% the size of my square).

I have used this function in a precedent game and there was no pb.
What can cause this strange behavior ? I have tried different combination on the "absolute or relative" positions but it does not seem to change anything.

NB : the studio project is "Badguizmotestun".

Thank you all for your clues ;)
Official BGA developper newb :oops:
User avatar
paramesis
Posts: 398
Joined: 28 April 2020, 05:00

Re: Problem with "attachtonewparent"

Post by paramesis »

Do you have a CSS transform applied to either parent element? attachToNewParent uses dojo.position, similar to placeOnObjectPos and slideToObjectPos, which produce unexpected results when CSS transforms are involved. See this post for more info:

https://boardgamearena.com/forum/viewto ... 189#p51274
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Problem with "attachtonewparent"

Post by Badguizmo »

paramesis wrote: 16 July 2021, 02:35 Do you have a CSS transform applied to either parent element? attachToNewParent uses dojo.position, similar to placeOnObjectPos and slideToObjectPos, which produce unexpected results when CSS transforms are involved. See this post for more info:

https://boardgamearena.com/forum/viewto ... 189#p51274
Hello.

I saw this thread before. Maybe

The only CSS transform I am doing is when hovering :

Code: Select all

.square-possible-selection:hover {
    transform: scale(1.1);
    z-index: 100; 
}
When desactivating it, apparently my problem is solved.
Now I have to deal with this. I will try to remove the class before moving the element ;)

But maybe I was doing this in my previous game code, that is why I passed trought this behaviour :oops: :oops: :oops:
Official BGA developper newb :oops:
User avatar
Galeelox
Posts: 17
Joined: 14 March 2017, 12:17

Re: Problem with "attachtonewparent"

Post by Galeelox »

You can set a scale of 1, then attach to new parent, and set the scale to 1.1.
It's so quick that you can't notice it.
Post Reply

Return to “Developers”