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

2020/3/14

How do I make a damage using a player to another player?

CieloMungcal CieloMungcal

2020/3/14

#
how can i decrease damage in my healthbar
danpost danpost

2020/3/14

#
???
CieloMungcal CieloMungcal

2020/3/14

#
i have a player1 with a healthbar i need player1 healthbar to decrease everytime player2 hits player 1 @danpost do you have a sample game for this? or can u make a multiplayer game where 2 players fight? please need a sample code for this
CieloMungcal CieloMungcal

2020/3/14

#
java.lang.IllegalStateException: Actor not in world. An attempt was made to use the actor's location while it is not in the world. Either it has not yet been inserted, or it has been removed. at greenfoot.Actor.failIfNotInWorld(Actor.java:713) at greenfoot.Actor.getOneIntersectingObject(Actor.java:964) at slash2.handleCollisions(slash2.java:10) at slash2.act(slash2.java:45)
CieloMungcal CieloMungcal

2020/3/14

#
how do i fix this error
CieloMungcal CieloMungcal

2020/3/14

#
//this is what brings damage to the player import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) public class slash2 extends Actor { private int slashcount; int collisionCountdown = 0; // Need to slowdown losing health public void handleCollisions() { Actor Hero = getOneIntersectingObject(Hero.class); if( Hero != null ) { HBWorld w = (HBWorld) getWorld(); w.subtractHealth(5); collisionCountdown = 0; } } public slash2() { GreenfootImage image = getImage(); image.scale(image.getWidth() -250 , image.getHeight() -250 ); setRotation(-50); setImage(image); } public void slash2() { if (Greenfoot.isKeyDown("down")) { getWorld().addObject(new slash2(), getX() + 50, getY()); } } public void act() { slashCount(); if( collisionCountdown > 0 ) { collisionCountdown--; } else { handleCollisions(); } } public void slashCount() { if (Greenfoot.isKeyDown("down")) { slashcount++; }else { getWorld().removeObject(this); } if (slashcount>=2) { getWorld().removeObject(this); } } }
CieloMungcal CieloMungcal

2020/3/14

#
whenever 'slash' hits my hero.. game stops saying theres an error
danpost danpost

2020/3/14

#
CieloMungcal wrote...
whenever 'slash' hits my hero.. game stops saying theres an error
Insert as 2nd line in act:
if (getWorld() == null) return;
You need to login to post a reply.