Hello
I'm looking for a smart way to turn my snowballs into the right direction. I use them to destroy the enemy....
The direction depends on the direction of another actor. I found some sultions, where I have to name the snowballs, but because of the fact that there can be multiple Snowballs in the game at the same time, it would make it way more complicatet to give them a name when I create them (I guess...)
I had a simple idea, but I dont know why it doesn't work. This method is called in the act-method in the Snowball-Class.
Instead of the Method above, I think the best idea would be to work with the getRotation() and setRotation(), but I had issues with set them up right. Even the tutorial "How to access one object from another" couldn't help me. : (
My World is named Labyrinth, the class I want the rotation of is named Player (actor; player). The Class Snowball needs the access...
Can someone pls help me with getting the Rotation of the player.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public void direction(){ if (singleAct == 0 ){ if (Greenfoot.isKeyDown( "a" )){ // Left setRotation( 180 ); } else if (Greenfoot.isKeyDown( "d" )){ // Right setRotation( 0 ); } else if (Greenfoot.isKeyDown( "w" )){ // Up setRotation(- 90 ); } else if (Greenfoot.isKeyDown( "s" )){ // Down setRotation( 90 ); } System.out.println(singleAct); singleAct = 1 ; } } |