slideTemporaryObject throwing an error

Game development with Board Game Arena Studio
Post Reply
User avatar
BrianHanechak
Posts: 7
Joined: 06 October 2012, 19:18

slideTemporaryObject throwing an error

Post by BrianHanechak »

I've been trying to add animation to my game. I am attempting to do this using 'slideTemporaryObject', although I'm not sure this is the best way for me to do it.

The error I get, consistently, is:

TypeError: Cannot read property of 'ownerDocument' of null

I can't seem to get a reliable stack trace from this, although if I quickly cust-and-paste it from the screen, it looks like this:

Javascript error:
During notification cardDiscarded
Cannot read property 'ownerDocument' of null
TypeError: Cannot read property 'ownerDocument' of null
at Object.geom.position (http://en.1.studio.boardgamearena.com/t ... s:15:72113)
at _62b.slideToObject (http://en.1.studio.boardgamearena.com/t ... :15:253601)
at _62b.slideTemporaryObject (http://en.1.studio.boardgamearena.com/t ... :15:255821)

I've checked, and both the 'from' object and the 'to' object exist in the dom. It also seems to create the temporary object and place it on the screen.

Any ideas?
User avatar
BrianHanechak
Posts: 7
Joined: 06 October 2012, 19:18

Re: slideTemporaryObject throwing an error

Post by BrianHanechak »

It may be worth jumping ahead and asking for help with what I really want to do with this.

I'm working on a card game where a common action is to move a card from one place to another. The two places are usually (but not always) modeled with different "stock" objects. (The destination as of now is always a stock object; sometimes the source is a stock object but sometimes it's just going to be a newly-materialized card.)

Right now, I'm removing the item from one stock and adding it to the other. This works but it's not easy for players to see what's happening. Is there a good way to animate the object smoothly from one location to another?

- Brian
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: slideTemporaryObject throwing an error

Post by sourisdudesert »

Hello,

The usual way is the following:
  • When you add a card to a stock item, and this card is not coming from another stock: use "addToStockWithId" with a "from" argument set to the element of your interface where card should come from.
  • When you add a card to a stock item, and this card is coming from another stock:
    - on the destination Stock, use "addToStockWithId" with a "from" equals to the HTML id of the corresponding item in the source Stock. For example, If the source stock id is "myHand", then the HTML id of card 48 is "myHand_item_48".
    - then, remove the source item with "removeFromStockById".
    (note that it's important to do things in this order, because source item must still exists when you use it as the origin of the slide).
  • When you move a card from a stock item to something that is not a stock item:
    - insert the card as a classic HTML template (dojo.place / this.format_block).
    - place it on the Stock item with "this.placeOnObject", using Stock item HTML id (see above).
    - slide it to its new position with "this.slideToObject"
    - remove the card from the Stock item with "removeFromStockById".
Using the methods above, your cards should slided to, from and between your Stock controls smoothly :)
User avatar
sourisdudesert
Administrateur
Posts: 4630
Joined: 23 January 2010, 22:02

Re: slideTemporaryObject throwing an error

Post by sourisdudesert »

By the way, concerning your original error, are you sure of the order of your arguments? It should be:
this.slideTemporaryObject( mobile_obj_html, mobile_obj_parent, from, to, duration, delay )
User avatar
BrianHanechak
Posts: 7
Joined: 06 October 2012, 19:18

Re: slideTemporaryObject throwing an error

Post by BrianHanechak »

I somehow had missed the 'from' argument on the stock 'add' methods. This works great, and is a lot easier than I thought it might be.

Thanks!

- Brian
Post Reply

Return to “Developers”