This post has been removed by the user
Sorry, I can’t make out exactly what behavior you want. Describing what you want clearly is always the first step towards being able to code it, so maybe you can try again? ![]()
In terms of keys (and/or mouse inputs), what exactly do you want your sprite to do?
OK, yes, now I understand what you’re trying to do. Almost. How should your sprite face when it is (say) moving right but firing left? Three options come to mind:
- Sprite should always reflect which way it’s firing. In this case, your movement code should move the sprite but not change which sprite shape is shown; and the firing code should change the sprite but (of course) not move it.
- Sprite should always reflect which way it’s moving. In this case, your current movement code is fine, both moving and changing the sprite image. The firing code should ignore what sprite image is shown and (entirely separately) spawn the projectile in the aim direction.
- Or, maybe you divide your sprite into two parts, a base that always points/animates in the direction you’re moving, and a top that always points in the direction you’re aiming. In that case the movement code should control the former, and the firing code control the latter.
Does this help? I think you just need to separate your movement and firing code (right now they are mixed together), and have each one do whatever you want it to do.