i got a konami code for my game as an Easter egg an if you type it correct an int increases by 1 or a boolean gets set to true its not important if its a boolean or int for me
but now i want to use the int/boolean in another actor so when you typed the konami code the weachter is no longer able to (kill = toeten) the abenteurer but rCount is not a declared variable in the actor weachter
so how can i access a Boolean/int From Another Actor Class
public void Toeten()
{
if(rCount == false or rCount == 0){
if ((isTouching(Abenteurer.class)))
{
GameEnd myImage = new GameEnd ();
World w = getWorld();
w.addObject(myImage, 9, 9);
myImage.setImage("WG.png");
Greenfoot.stop();
}
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | private static final String[] konamiKeys = { "up" , "up" , "down" , "down" , "left" , "right" , "left" , "right" , "b" , "a" , "enter" }; private int keyIndex = 0 ; public void konami() { String key = Greenfoot.getKey(); if (key != null ) { if (konamiKeys[keyIndex].equals(key)) // is next key in sequence { if (++keyIndex == konamiKeys.length) // is last key in sequence { //rCount = true; //rCount = 1; keyIndex = 0 ; } } else // not in sequence -- start over { keyIndex = 0 ; } } } private int pngCount = 0 ; //public int rCount = 0; //public boolean rCount = false; public void delayCounting() { pngCount++; if (pngCount == 14 ) { pngCount = 0 ; } } void Rainbow() { if (rCount == true or rCount == 1 ){ if (pngCount == 2 ) { setImage( "ACO.png" ); } if (pngCount == 4 ){ setImage( "ACY.png" ); } if (pngCount == 6 ){ setImage( "ACG.png" ); } if (pngCount == 8 ){ setImage( "ACLB.png" ); } if (pngCount == 10 ){ setImage( "ACB.png" ); } if (pngCount == 12 ){ setImage( "ACP.png" ); } if (pngCount == 14 ){ setImage( "abenteurer.png" ); } if ((isTouching(Waechter. class ))) { GameEnd myImage = new GameEnd (); World w = getWorld(); w.addObject(myImage, 9 , 9 ); myImage.setImage( "GG.png" ); Greenfoot.stop(); } } } } |