Page 1 of 1
How can I get a path of resource folder?
Posted: 15 December 2017, 01:45
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.
Re: How can I get a path of resource folder?
Posted: 15 December 2017, 22:58
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>";
Re: How can I get a path of resource folder?
Posted: 16 December 2017, 05:47
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)?
Re: How can I get a path of resource folder?
Posted: 18 December 2017, 14:14
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 {