struggling with dojo

Game development with Board Game Arena Studio
Post Reply
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

struggling with dojo

Post by tchobello »

hello, i'm been looking for what is wrong for several days...
I can't find it and I always get a
Javascript error:
During notification placeDarkTile
Cannot read property 'ownerDocument' of null
TypeError: Cannot read property 'ownerDocument' of null
at Object.place
...
at Object.placeDarkTile
...
at Object.notif_placeDarkTile
...

TPL :
var jstpl_darktile = '<div id="darknesstile_${id}" class="darktile darktile_${type}"></div>';


CSS :
.darktile {
background-image: url('img/darkness.jpg');
background-size: 1000% 600%;
width: 75px;
position: absolute;
}

.darktile_1 { background-position: -0% -0%; height: 75px; }
.darktile_2 { background-position: -100% -0%; height: 150px; }
...
.darktile_30 { background-position: -200% -0%; height: 225px;}
PHP
function illuminate( $illuminator_id, $x, $y, $dir )
{
$darktile_type = bga_rand(1,30);
self::notifyAllPlayers( 'placeDarkTile', clienttranslate('${player_name}`s ${illuminator_name} illuminates ${x} - ${y} with darktile ${darktile_type}'), array(
'i18n' => array( 'illuminator_name' ),
'player_name' => self::getActivePlayerName(),
'illuminator_name' => $this->token_types[ $illuminator['type'] ]['name'],
'darktile_type' => $darktile_type,
'x' => $x,
'y' => $y
) );
}

JS
notif_placeDarkTile: function( notif )
{
this.placeDarkTile( notif.args.x, notif.args.y, notif.args.darktile_type );
},
placeDarkTile: function( x, y, darktile_type )
{
dojo.place( this.format_block( 'jstpl_darktile', {
id :darktile_type,
type: darktile_type
} ), 'darktiles' );

this.placeOnObject( 'darknesstile_'+id, 'square_'+x+'_'+y );
},
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: struggling with dojo

Post by Een »

I think one of the dom nodes you are trying to place another node in is null.
You can check for the existence of the nodes with something like

Code: Select all

if ($('square_'+x+'_'+y) == null) alert('square_'+x+'_'+y);
and once you know which node is null you can investigate why.
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: struggling with dojo

Post by tchobello »

problem solved.
last argument of dojo.place is a node declared in TPL...
Front-End is evil.
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: struggling with dojo

Post by tchobello »

hello...

I have another problem with sprites.

A sprite has a width of 75 and I want it to adapt to screen size.

When I change screen size, sprite size changes also but I have a cropped image instead of a resized one...
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: struggling with dojo

Post by Een »

Hello again :)
You can use background-size to resize an image div background. Usually, we use a larger than needed background image and resize it with background-size so that the image stays crisp when the browser zoom is used.
User avatar
tchobello
Posts: 694
Joined: 18 March 2012, 13:19

Re: struggling with dojo

Post by tchobello »

damnit ! It worked with % !
I also had to make some tricks as sprites have different heights.
Post Reply

Return to “Developers”