This is what my vegitables.java looks like
public class Vegitable extends Context {
String type;
int side, position;
public Vegitable(int side, int position) {
if(side < 3 && side > 0 && position < 3 && position > 0) {
this.side = side;
this.position = position;
this.setRand();
}
}
public String getType() {
return this.type;
}
public boolean setRand() {
Random rr = new Random();
switch(rr.nextInt(3 - 1) + 1) {
case 1:
this.type = "Onion";
break;
case 2:
this.type = "Pepperoni";
break;
default:
return false;
}
return true;
}
In my Main.Activity i want to randomly generate eighter an onion or a pepperoni. (Like this:)
public void spawn() {
if(this.vegi.length > 30)
return;
Random r = new Random();
if(r.nextInt(this.spawnRotationMax - 1) + 1 != 1)
return;
this.vegi[vegiNum] = new Vegitable(r.nextInt(3 - 1) + 1,r.nextInt(3 - 1) + 1);
//this.vegi[1].getResources().getDrawable(R.drawable.charab);
if (vegi[vegiNum].type.equals("Pepperoni")){}
Toast.makeText(GameAcvitiy.this, this.vegi[vegiNum].getType(), Toast.LENGTH_LONG).show();
vegiNum++;
My question is : Where and how can i give my vegi objects an image so i can see and use them in my Main.Activity ? (I want to let em collide later on)
Thank you !