This site requires JavaScript, please enable it in your browser!
Greenfoot back
footpickle
footpickle wrote ...

2020/3/5

How to properly use setImage?

1
2
3
footpickle footpickle

2020/3/7

#
The health bar hovers on the boss, instead of over it. Do I just change this line?
1
bossHealth.setLocation(getX(), getY()-30);
danpost danpost

2020/3/7

#
footpickle wrote...
The health bar hovers on the boss, instead of over it. Do I just change this line? << Code Omitted >>
Yes -- just increase the "30" as needed.
footpickle footpickle

2020/3/7

#
Oh, I only want one health to decrease the moment the bomb hits the boss. The boss has 180 health, and I want the fight to last over a minute. The bomb does quite a lot of damage per hit, though. I also labelled my health sprites the wrong way round, so 1 is almost full, and 180 is dead.
footpickle footpickle

2020/3/7

#
So the healthbar works, and it proves that the health goes down rapidly. Would a subclass of the bomb count as a bomb?
danpost danpost

2020/3/7

#
I guess you would then need a field to track when the boss is touching a bomb. Keep the field updated and only give damage when the field goes from false to true.
danpost danpost

2020/3/7

#
footpickle wrote...
So the healthbar works, and it proves that the health goes down rapidly. Would a subclass of the bomb count as a bomb?
Yes.
footpickle footpickle

2020/3/7

#
Ok! that works now! BUT... (there is always a but, purely because I am dumb) I can't shoot the boss. I have a scrolling world, but nothing can leave the world. It all just slides along the edge and then sits in the corner of the screen. Is there a way to remove the world border?
danpost danpost

2020/3/7

#
footpickle wrote...
Ok! that works now! BUT... (there is always a but, purely because I am dumb) I can't shoot the boss. I have a scrolling world, but nothing can leave the world. It all just slides along the edge and then sits in the corner of the screen. Is there a way to remove the world border?
You can unbound your world by using the alternate World constructor: World(int, int, int, boolean). Set the boolean to false.
footpickle footpickle

2020/3/7

#
Where in the world class is that? Or do you mean put that in somewhere myself? if so, where?
danpost danpost

2020/3/7

#
footpickle wrote...
Where in the world class is that? Or do you mean put that in somewhere myself? if so, where?
Look for the word super.
footpickle footpickle

2020/3/7

#
so where it says super, what do I actually do? I'm not understanding fully.
footpickle footpickle

2020/3/7

#
Wait, I did it. IT WORKS. :) Thanks so much!
footpickle footpickle

2020/3/7

#
Earlier I asked if there was a way to make this:
1
setImage(new GreenfootImage("Health"+health+".png"));
go in reverse (so the image instead of going 1, 2, 3, 4, 5 etc, it goes 5, 4, 3, 2, 1.) Is there a way to do this, or have I wasted hours making my health bar?
footpickle footpickle

2020/3/7

#
I'm also trying to add some "cool" asteroids that when one hits the edge of the world, it creates a new one somewhere on the screen, but it duplicates over and over until the screen is just a bunch of rocks. I THINK the problem may be the fact that the code is in the act() method, which I've heard repeats itself.
footpickle footpickle

2020/3/7

#
I figured it out and fixed it :) I've now made it so when the boss hits the main actor (Plane2) it triggers an explosion, and then Plane2 disappears. That then screws up some of the bosses code that makes the boss follow the player. I made the plane NOT disappear and now there are so many explosions my game lags a lot. I'm stumped as to what to do. I guess it's either a laggy game or no game...
There are more replies on the next page.
1
2
3