Substracting width only from the right side

This forum is currently in read-only mode.
From the Asset Store
Build your own spaceship for your side scroller space shooter games with various components.
  • I know I'm not the master of thread titles, so here's an example.

    I'm developing a UI backend to use in my new game (That Namelezz Game), but the HP bar should not shrink from both directions, only from right.

    Here's a screenie:

    HP is 100 - Width is then 100.

    <img src="http://img341.imageshack.us/img341/7443/normalhpmm8.png">

    HP is lost and width is lost - but it shrinks the sprite from both sides!

    <img src="http://img341.imageshack.us/img341/4441/losthpli6.png">

    How can I make it so the width only gets substracted from the right?

    EDIT:

    Just as I finished writing I just changed the hotspot to the left corner and it worked, nevermind

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you use Sprite to render this counter:

    Try putting Pivot Point in the top-left corner

    If you use Box for example named MyBox or any other object:

    I'd recommend using Sprite showing bar when full

    But you can also always set this MyBox's X position. Let's say Box's starting X position is stored in value ('startX') and starting width in value ('startWidth'). Then in events you can make:

    Event #1:

    Conditions:

    -> Always (every tick)

    Actions:

    -> MyBox . Set X Position to: MyBox('startX') - (MyBox('startWidth') - MyBox.Width) / 2.

    Maybe there are more optimal solutions but I don't mind wasting 1000 CPU cycles per frame ^^.

  • Yes, the pivot point trick worked! Thanks.

    Now JAWS (Just Another Window System) is even greater

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