[Beye] PlainClick is not defined

Game development with Board Game Arena Studio
Post Reply
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

[Beye] PlainClick is not defined

Post by Rudolf »

Bon, j'ai un petit soucis sur l'utilisation d'une fonction en appel à 2 paramètres:
dans le .js

Code: Select all

// TODO: Set up your game interface here, according to "gamedatas"
            	for ( var id in gamedatas.plaincards )
	    	{
			var card = gamedatas.plaincards[id];
			var r = card.plain_row;
			var c = card.plain_col;
			var i =	card.plain_card;		
			var s = card.plain_status;
			if (s==-1) // Empty
				dojo.style("p"+r+c, "backgroundPosition", "40px");
			else
				dojo.style("p"+r+c, "backgroundPosition", -(i *40) + "px");
                        // dojo.connect('p'+r+c,'onclick',this,'PlainClick('+r+','+c+')');
                        // dojo.connect('p'+r+c,'onclick','PlainClick('+r+','+c+')');
			dojo.connect('p'+r+c,'onclick',PlainClick(r,c));
		}
un peu plus loin:

Code: Select all

///////////////////////////////////////////////////
        //// Utility methods
        
        /*
        
            Here, you can defines some utility methods that you can use everywhere in your javascript
            script.
        
        */
	PlainClick: function (ROW,COL)
	{
		this.showMessage("Plain ="+ROW+COL, 'error' );
		
	},        
Quelqu'un peut m'expliquer ce qui ne colle pas? pourquoi j'ai un PlainClick not defined?
NB: I've tested also with or without quotes, put the function upper, ... nothing change.
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: [Beye] PlainClick is not defined

Post by Rudolf »

Bon entretemps, j'essaye de changer de methode avec:
dojo.connect("r_"+r+'_'+c, 'onclick', this, 'RockClick');
(j'ai rajouté des _ dans le tpl)

RockClick: function ()//ROW,COL)
{
this.showMessage("Rock=", 'error' );

}

cette fois j'ai le message d'erreur suivant:
Javascript error:
During pageload
undefined
no_stack_avail
Script:
Url: http://en.1.studio.boardgamearena.com/b ... table=3446
U=2243091
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: [Beye] PlainClick is not defined

Post by Een »

Hi Rudolf,

The second solution is the good one, except that your RockClick function must be defined with an 'evt' parameter.
See http://en.doc.boardgamearena.com/Game_i ... yers_input for some more info on dojo.connect, and http://en.doc.boardgamearena.com/Tutori ... and_events (function onClickIntersection) for an example of how to get your coordinates parsed from the id of the div that was clicked on.
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: [Beye] PlainClick is not defined

Post by Rudolf »

thanks, but I still have the pb of "stack not available"...

with

dojo.connect("r_"+r+'_'+c, 'onclick', 'RockClick');
Or
dojo.connect("r_"+r+'_'+c, 'onclick',this, 'RockClick');

And

RockClick: function (evt) //ROW,COL)
{
this.showMessage("ok", 'error' );
},
User avatar
Een
Posts: 3861
Joined: 16 June 2010, 19:52

Re: [Beye] PlainClick is not defined

Post by Een »

Here is the correct code to use:

Code: Select all

dojo.connect( $('r_'+r+'_'+c) , 'onclick', this, 'RockClick');
You must use the element reference $('element_id') for the first parameter, and 'this' as the third parameter.
User avatar
Rudolf
Posts: 566
Joined: 24 December 2011, 23:04

Re: [Beye] PlainClick is not defined

Post by Rudolf »

ok!!!!
Post Reply

Return to “Developers”