![]() However, If the "q" key is not pressed, as you can see in the code I provided before, the standing() function will execute and spiderman will remain standing and its image will also be set as an image which shows him as standing. When shielding, the spiderman's image is set as a specific image which shows himself as if he is shielding. Using getOneObjectAtOffset(0, 0, Collisions.class), no detection will be made until the colliding object reaches the center of the player. If not, then keeps image number the same. As you are probably aware, your code is bulky, as well as troublesome. Changes the number of the image if the animation is still needed. GreenfootImage img = new GreenfootImage("PaulShielding-" + imageNum + ".png") Quick question, what String represents the numbers on the number pad, what represents the Alt key. Instead of checking what might be around the hero beforehand, just move the hero as directed by the user and then check what is at that location if something like a wall, block or border is there, reverse the move. ![]() Sets which direction Paul is facing while using shield I doubt you need all the fields on lines 13 and 20 of the Hero class. For every 12 times I call this method, Paul changes image Increments the amount of times this method was called so i ruined my game that i was making and now it barely works like it was meant to here is the source code its due today. Paul is shielding from attacks so he will take reduced damage from enemies Added autocomplete support for Greenfoot.isKeyDown (and similar static methods) by just completing on 'Gr' and similar. May 2022) Bug fixes in Java and Stride editors. If Paul just activated his shield, then imageNum resets. October 2022) Mac only release to fix issue with crashing on load in macOS 13 (Ventura). Makes Paul go down a platform whenever the "down" key is pressed I'm trying to make a game where there are walls in the level, is there a way that I could make a series of invisible walls quickly as the level has alot of walls. You need to put the setLocation call inside the if-statement, but you can leave the image changing code outside of it (to still have the effect of changing the orientation of Roodkapje/Red riding hood, even when she cant move). Makes Paul jump whenever the "space" key is pressed The problem is youre moving your character with the setLocation method, but then after that youre checking for collisions. That is, it is useless using it before the actor is added into the world and, that does not happen until after construction. If none of the keys are pressed, Paul remains standing idle The getWorld method will always have a null value during Player construction. Use methods such as isKeyDown, setRotation and move. Makes Paul attacks whenever the "e" key is pressed Learn how to edit code in Greenfoot to make objects move using the arrow keys. Makes Paul shoot his web bolt whenever the "w" key is pressed Makes Paul move in the left direction whenever the "left" key is pressed Makes Paul use his shield whenever the "q" key is pressed ![]() This set of if statements makes sure that Paul can't move while using any skills
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |