I created a scenario which uses the isKeyDown() function multiple times, but it seems like they're not executing fast enough to finish the full animation.
Scenario
This is my scenario, and the problem occurs whenever I hold Q, W, or R. The arrow keys that make spiderman move work properly but whenever I press Q it seems to not do full animation, which is supposed to be spiderman creating a web shield. I am using the checkKeys() method in the act() method to check the keys that the user presses.
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 | public void act() { checkKeys(); checkFall(); nextLevel(); pickUpUSB(); checkGameWin(); checkDie(); } public void checkKeys() { //This set of if statements makes sure that Paul can't move while using any skills //Makes Paul use his shield whenever the "q" key is pressed if (Greenfoot.isKeyDown( "q" )){ if (!inAir){ shield(); } } else { isShielding = false ; if (Greenfoot.isKeyDown( "right" )){ moveRight(); } //Makes Paul move in the left direction whenever the "left" key is pressed else if (Greenfoot.isKeyDown( "left" )){ moveLeft(); } else { if (isWalking){ isWalking = false ; } //Makes Paul shoot his web bolt whenever the "w" key is pressed if (Greenfoot.isKeyDown( "w" )){ if (!inAir){ shootWeb(); } } //Makes Paul attacks whenever the "e" key is pressed else if (Greenfoot.isKeyDown( "e" )){ if (!inAir){ attack(); } } //If none of the keys are pressed, Paul remains standing idle else { standing(); } } } //Makes Paul jump whenever the "space" key is pressed if (Greenfoot.isKeyDown( "space" )){ if (!inAir){ jump(); } } //Makes Paul go down a platform whenever the "down" key is pressed if (Greenfoot.isKeyDown( "down" )){ downPlatform(); } } |