I'm a beginner in coding, so sorry if I'm missing something obvious.
When Jett hits a fuel cell, she gains energy. When energy is at a certain point, I want the Cell Bar to switch image.
So I want Jett to send the int energy to GaugeBar.
I'm a little lost at this - how do I get this to work?
Here's what I have: (Please ignore the comments, they're all Act as of now)
And here's GaugeBar:
Thank you, in advance
public class Jett extends Actor
{
public int energy;
/**
* Act - do whatever the Jett wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public Jett()
{
// Add your action code here.
}
/**
* Act - do whatever the Jett wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
move(1);
energyUp();
}
/**
* Act - do whatever the Jett wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void energyUp()
{
if (isTouching(Fuellcell.class))
{
removeTouching(Fuellcell.class);
energy = energy + 1;
}
}
public int getEnergy()
{
return energy;
}
public void setEnergy(int energy)
{
energy = energy;
}public class GaugeBar extends CG
{
public int energy;
/**
* Act - do whatever the GaugeBar wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public GaugeBar()
{
}
/**
* Act - do whatever the GaugeBar wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void act()
{
energyCollector();
}
Actor Jett;
Jett jettObj = (Jett) getOneObjectAtOffset(0, 0, Jett.class);
/**
* Act - do whatever the GaugeBar wants to do. This method is called whenever
* the 'Act' or 'Run' button gets pressed in the environment.
*/
public void energyCollector()
{
// to get
int energy = jettObj.getEnergy();
// to set
jettObj.setEnergy(energy);
}
}

