Substracting width only from the right side

For questions about using Classic.

Post » Wed Oct 22, 2008 4:57 pm

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.


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


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 :D
B
4
S
2
G
6
Posts: 50
Reputation: 1,690

Post » Wed Oct 22, 2008 5:02 pm

If you use Sprite to render this counter:
:arrow: Try putting Pivot Point in the top-left corner

If you use Box for example named MyBox or any other object:
:arrow: I'd recommend using Sprite showing bar when full
:arrow: 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 ^^.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Wed Oct 22, 2008 5:17 pm

Yes, the pivot point trick worked! Thanks.
Now JAWS (Just Another Window System) is even greater :P
B
4
S
2
G
6
Posts: 50
Reputation: 1,690


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 5 guests