[SOLVED] Difference placeOnObjectPos and slideToObjectPos

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

[SOLVED] Difference placeOnObjectPos and slideToObjectPos

Post by Badguizmo »

Hello.
I am facing a strange behavior.

I have a card that receive a token damage.
When adding this token damage during "normal play" I am using this code in a function named "applydamage" :

Code: Select all

dojo.place(this.format_block('jstpl_damage_token', {
	damageValue: 3,
	cardId: cardId,
	tokenIndex: 1
}), 'card_'+cardId,'last');
this.placeOnObject('token_damage_' + cardId+'_1', 'overall_player_board_' + this.getActivePlayerId());
this.slideToObjectPos('token_damage_' + cardId+'_1', 'card_'+cardId,horizontalPosition,verticalPostion).play();
In CSS :

Code: Select all

.token-normal-card{
position: relative;
}
.card-elemental {
position: absolute;
}
The token damage is placed on "top" of the card and with an offset to the left ==> witch is GOOD.

But I have also coded a function for refreshing the page named "setupApplyDamage" :

Code: Select all

dojo.place(this.format_block('jstpl_damage_token', {
	damageValue: 3,
	cardId: cardId,
	tokenIndex: 1
}), 'card_' + cardId, 'last');
this.placeOnObjectPos('token_damage_' + cardId + '_1', 'card_' + cardId, horizontalPosition, verticalPostion);
But now the offsets are applyed from the center of the card.
I have to modify the style to have the token at the right place

Code: Select all

dojo.style('token_damage_' + cardId + '_1',topOrBottom, verticalPosition + 'px');
dojo.style('token_damage_' + cardId + '_1','left', horizontalPosition + 'px');
Is it normal behavior that these two function does not react the same or am I missing something ... again ? :D

NB there is also this topic viewtopic.php?f=12&t=14189&hilit=placeOnObjectPos but I did not linked both problems (for now).

Thank you all ^^
Last edited by Badguizmo on 08 May 2021, 23:26, edited 1 time in total.
Official BGA developper newb :oops:
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Difference placeOnObjectPos and slideToObjectPos

Post by Victoria_La »

You sure horizontalPosition, etc is defined when you reload? Placing card in center is default behavior when these are undefined...
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: Difference placeOnObjectPos and slideToObjectPos

Post by tchobello »

I've had the same behavior....

placeOnObject
slideToObject
SlideToObjectPos centers

placeOnObjectPos do not.
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: Difference placeOnObjectPos and slideToObjectPos

Post by Badguizmo »

Victoria_La wrote: 07 May 2021, 20:57 You sure horizontalPosition, etc is defined when you reload? Placing card in center is default behavior when these are undefined...
Yes. Checked with "console.log" before calling methods.
tchobello wrote: 07 May 2021, 21:06 I've had the same behavior....

placeOnObject
slideToObject
SlideToObjectPos centers

placeOnObjectPos do not.

Mouarf ...

What I can do is maybe re-use the place and slidetoobjectpos(.....).play() even if it is for the page refresh ?
Official BGA developper newb :oops:
User avatar
Victoria_La
Posts: 665
Joined: 28 December 2015, 20:55

Re: Difference placeOnObjectPos and slideToObjectPos

Post by Victoria_La »

By reading the code placeOnObject centers it and the other one does not (i.e x,y offset of the center)
But you can do slideToObject even during reload, it actually smart enought to reduce the animation to 1ms in this case.
User avatar
Badguizmo
Posts: 76
Joined: 11 October 2020, 14:27

Re: [SOLVED] Difference placeOnObjectPos and slideToObjectPos

Post by Badguizmo »

Thank you.
Will do that ;)
Official BGA developper newb :oops:
Post Reply

Return to “Developers”