How do i prevent sprite from it being visible out of borders?

0 favourites
  • 4 posts
From the Asset Store
Minimal Sprite Font with Stroke for Pixel Art games.
  • So im making dungeon-crawler like game and i ran into problem.

    when mouse overlaps an enemy and the player clicks M1 the wound sprite spawns at the current mouse x,y to represent damage dealt. The problem is that the sprite of wound can go out of enemy sprite so part of it kinda weirdly hangs in air. Any idea how can i possinbly fix it so the wound still appears where the player clicked but doesnt go out of bounds?

  • Check the position of the mouse relative to the position of the enemy before spawning a wound. And if it goes beyond its limits, change the position of the wound.

  • dropmefiles.com.ua/en/NSQfc5W

    This is a simple example.

    We move the wound if it goes beyond the object.

    Use the width and height of the object.

    Everything will be fine if the object is close to a square.

    If the object will have a more complex shape, then we will have to change the method of inflicting wounds.

    There is a second option we can use on the wound blending mode.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey thanks a lot for reply! I actually found the best solution by setting the wound on source a top blending mod "source a top" works great for the case.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)