Hi there,
I want ask you guys, how to inheritance the "act" function or what to do when I can't use both in one class(in Interface.class) and also don't want use this long code in every map class). Image:
Photo
In Interface.class public void act() I have
And in village/fight nothing. Now what I need is - function:
Put to Village and Fight acts but then I can't use save/load from Interface... How to make it workable? (I don't want use save/load in every class of map.) I want be to able save/load(when I will have save n load in Interface.class and also want to make that second code functionable for every map).
Is there any way for do that? Thanks
public void act()
{
UserInfo myInfo = UserInfo.getMyInfo();
//save n load
if(Greenfoot.isKeyDown("i")){
myInfo.setInt(0,level);
myInfo.setInt(1,xp);
myInfo.setInt(2,xpNeed);
myInfo.setInt(3,hpMax);
myInfo.setInt(4,mpMax);
myInfo.setInt(5,coins);
myInfo.store();
}
if(Greenfoot.isKeyDown("o")){
level = myInfo.getInt(0);
xp = myInfo.getInt(1);
xpNeed = myInfo.getInt(2);
hpMax = myInfo.getInt(3);
mpMax = myInfo.getInt(4);
coins = myInfo.getInt(5);
adjustLevel(0, true);
adjustXp(0, true);
adjustLife(0, true);
adjustMana(0, true);
adjustCoins(0, true);
}
for (Actor a : getObjects(Actor.class))
{
if (a.getX() > getWidth()-5){ removeObject(a); return;}
if (a.getX() < 5){ removeObject(a); return;}
if (a.getY() > getHeight()-5){ removeObject(a); return;}
if (a.getY() < 5){ removeObject(a); return;}
}
}for (Actor a : getObjects(Actor.class))
{
if (a.getX() > getWidth()-5){ removeObject(a); return;}
if (a.getX() < 5){ removeObject(a); return;}
if (a.getY() > getHeight()-5){ removeObject(a); return;}
if (a.getY() < 5){ removeObject(a); return;}
}
