我有以下项目https://github.com/pc-magas/faster/tree/master
由于某些原因在浏览器上的浏览器上(通过离子服务器)似乎是这样的:
但在我的设备上似乎是这样的:
图像的html通过将它们作为参数传递加载到此文件https://github.com/pc-magas/faster/blob/master/www/js/services.js上(对于标签,github中的复制粘贴显示为这样)。
function GameItem(icon,icon_destroyed,icon_marked,name)
{
var item=this;
item.icon=icon;//Icon for the normal situations
item.icon_destroyed=icon_destroyed;//Icon if the item is Destroyed
item.icon_marked=icon_marked;//Icon when the item is selected
/*
*A Characteristic name of the itemYourFactory
*It can Be used for comparisons ;)
*/
item.name=name;
/**
*For now takes 2 values:
*start if the Item is not destroyed
*destroyed if the item in destroyed
*whatever dtatus you want
*/
item.status="start";
/**
*The position of the Item
*Check if you need it
*/
item.posistion={x:0,y:0};
/**
*Clone the Object (used for Initialization)
*/
item.clone=function()
{
return new GameItem(item.icon,item.icon_destroyed,item.icon_marked,item.name)
}
/**
*Check if this item is equal with another one
*/
item.equals=function(other)
{
return other.name===item.name;
};
/**
*Gets The icon regarding the status of the Item is
*/
item.getIcon=function()
{
var icon="";
//Add here the status of the
switch(item.status)
{
case 'destroyed':
icon=item.icon_destroyed;
break;
case 'start':
icon=item.icon;
break;
default:
icon=item.icon;
}
return icon;
}
};//End of Item Class
我在游戏控制器中初始化此文件https://github.com/pc-magas/faster/blob/master/www/js/controllers.js中的游戏项目:
/**
*Items for the Game
*/
var items=[new GameItem('../img/icon1.jpg','../img/icon1.jpg','../img/icon1.jpg','trolley'),new GameItem('../img/icon2.jpg','../img/icon2.jpg','../img/icon2.jpg','metro'),new GameItem('../img/icon3.jpg','../img/icon3.jpg','../img/icon3.jpg','bus'),new GameItem('../img/icon4.jpg','../img/icon4.jpg','../img/icon4.jpg','tram'),];
但我不知道为什么会发生这种情况以及如何解决。
PS。我通过运行来构建它:
ionic build android
我按照以下方式安装:
adb install /home/pcmagas/Kwdikas/Javascript/Ionic/Faster/platforms/android/build/outputs/apk/android-debug.apk
答案 0 :(得分:1)
我刚刚更换了:
带有../img/icon1.jpg
的 img/icon1.jpg
像魅力一样工作