Slide icon from ActionButton to Player Board

Game development with Board Game Arena Studio
Post Reply
Fabian Viking
Posts: 4
Joined: 09 July 2021, 07:22

Slide icon from ActionButton to Player Board

Post by Fabian Viking »

Wanted to animate a token grabbed when pressing an action button.
Couldn't find any example, so here is my solution:

Code: Select all

let tokenId = `slidingToken_${this.uniqueId++}`;
dojo.place( this.format_block( 'jstpl_token', 
    {
        id: tokenId,
    } ) , "left-side");
    
this.placeOnObject( tokenId, 'pick_branchtoken');
let playerBoardLocation = "playerboard_icon_p" + notif.args.player_id;
let slide = this.slideToObject(tokenId, playerBoardLocation, 700);
var parent = this;        

dojo.connect( slide, 'onEnd', 
    function() 
    {
        dojo.destroy(tokenId);
        parent.visualRefreshPlayerBoards();                
    }
);

slide.play();
My template

Code: Select all

var jstpl_token='<div id="${id}" class="branchicon" style="position: absolute; z-index: 5;"></div>';
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Slide icon from ActionButton to Player Board

Post by Tisaac »

Not sure what your example is about exactly? Doing stuff at the end of an animation is already documented in the wiki.
And by the way, using 'parent = this' is no longer needed since ECMA 5 and arrow functions, just do "dojo.connect(slide, 'onEnd', () => { ... })".'
Post Reply

Return to “Developers”