How can I get a path of resource folder?

Game development with Board Game Arena Studio
Post Reply
stylix
Posts: 12
Joined: 16 March 2014, 15:33

How can I get a path of resource folder?

Post by stylix »

If I need to access additional php class file or image resources in xxx.view.php, xxx.game.php or xxx.js,
How can I get a path?
Simple adding <img src="img/cards.jpg"> doesn't show image properly.
User avatar
Victoria_La
Posts: 607
Joined: 28 December 2015, 20:55

Re: How can I get a path of resource folder?

Post by Victoria_La »

stylix wrote:If I need to access additional php class file or image resources in xxx.view.php, xxx.game.php or xxx.js,
How can I get a path?
Simple adding <img src="img/cards.jpg"> doesn't show image properly.
You can do it but you probably should not hardcoded paths in these file and use css instead

Code: Select all

.html
<div class="token"></div>

.css
.token {
  background-image: url(img/cards.jpg);
}
If you really insisting on have path in .js, its below, but nobody does <img> tags in bga games code now days

Code: Select all

.js

     // game resources
     
     return '<img src="'+g_gamethemeurl+'img/cards.jpg"/>';
     
        // shared resources
   return "<img class='imgtext' src='" + g_themeurl + "img/layout/help_click.png' alt='action' /> <span class='tooltiptext'>" +
                    text + "</span>";
                    
stylix
Posts: 12
Joined: 16 March 2014, 15:33

Re: How can I get a path of resource folder?

Post by stylix »

Victoria_La wrote:
stylix wrote:If I need to access additional php class file or image resources in xxx.view.php, xxx.game.php or xxx.js,
How can I get a path?
Simple adding <img src="img/cards.jpg"> doesn't show image properly.
You can do it but you probably should not hardcoded paths in these file and use css instead

Code: Select all

.html
<div class="token"></div>

.css
.token {
  background-image: url(img/cards.jpg);
}
If you really insisting on have path in .js, its below, but nobody does <img> tags in bga games code now days

Code: Select all

.js

     // game resources
     
     return '<img src="'+g_gamethemeurl+'img/cards.jpg"/>';
     
        // shared resources
   return "<img class='imgtext' src='" + g_themeurl + "img/layout/help_click.png' alt='action' /> <span class='tooltiptext'>" +
                    text + "</span>";
                    
Thanks.
How about additional PHP files for include (from xxx.game.php or xxx.view.php)?
User avatar
Victoria_La
Posts: 607
Joined: 28 December 2015, 20:55

Re: How can I get a path of resource folder?

Post by Victoria_La »

For php it should work as is.
This is example including a module from sharedcode project

Code: Select all

require_once (APP_GAMEMODULE_PATH . 'module/table/table.game.php');

require_once ('modules/tokens.php'); // <-- include my module

class SharedCode extends Table {
Post Reply

Return to “Developers”