lifebar - corner of screen even if moving

0 favourites
From the Asset Store
This is a code so you can see the same skin on all screens (peers). Each peer gets a skin, in addition to 4 directions t
  • What is the expression for the x and y positions of the top left corner of the screen?

    I need it for my lifebar. I already have anchor behavior and also separate HUD layer with 0,0 parallax. But I want to set the position through events because there are multiple layouts (levels) and I want to avoid having to manually move the lifebar for each layout.

    I already tried scrollx, scrolly and windowheight, windowwidth. so far, they don't work. I use start of layout as condition.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Have you tried these :

    ViewportBottom(layer)

    ViewportLeft(layer)

    ViewportRight(layer)

    ViewportTop(layer)

    Return the viewport boundaries in layout co-ordinates of a given layer. Not all layers have the same viewport if they are parallaxed, scaled or rotated separately.

  • yeah i tried the left and top of viewport too. doesn't change the position. It doesn't do anything.

  • Hmmm... The top left of the screen should always be 0,0 on a 0 parallax-ed layer.

    Make sure that the lifebar object exist on a layer with 0,0 parallax and 0 scale factor and on start of every layout set its position to 0,0.

    You can do that with code so it happens automatically for all layouts:

    On Start of Layout---> system | create "lifebar" on layer "HUD" at (0,0).

    Of course this means that a layer named "HUD" should exist on every layout with its parallax and scale factor values set to 0.

  • oh? I was using the Set Position since I already have 1 instance of it in the layout. ok. Now, I first used Destroy on the existing one then create a new one. Never thought of that. Thanks!

  • The Set Position should suffice for the first layout. I think that the anchor behavior was messing around with the position. You don't really need it, I think it's useful in circumstances like when the browser window change in size and you want the objects to dynamically adjust within the screen. Since you are interested in 0,0 coordinates, these do not change no matter what, so if you set the position once per layout you are ok!

  • eli0s

    My layouts are horizontally longer than the window size, so the game levels have a scrolling effect.

    I'm still using your method (destroy existing ones then create new ones). I did not use set position.

    I removed lifebar's anchor behavior, then I tried walking the character until the camera moves. The lifebar isn't scrolling.

    I put back the anchor behavior, the lifebar moves with the scrolling BUT it seems to fail to keep up with the scrolling. It's like there's an "earthquake effect" or "teetering effect" on the lifebar (not sure if I described the effect correctly) while the camera is scrolling.

    how do I fix this?

  • Make sure that the lifebar object exists on a layer with its parallax values set to 0,0! You can get access to a layer's properties by clicking on a layer and then look at the properties panel.

    All objects within a layer with 0,0 parallax values will not be affected by the scrolling. They will remain at their initial position on the screen, something that is ideal for HUDs.

  • eli0s

    it's ok already. I just forgot that I clicked undo on the changes I made to layer's scale but I forgot to change it back to 0

    Can you teach me how to create multiple lifebars (for multiple bosses) ?

    So far, this is what I did.

    Start of Layout

    ->store the number of boss objects (using count) into a global variable

    Then using that value, I need to create that same number of lifebars for each of the multiple bosses (top down from right side of screen)

    The single lifebar at the left is for the player.

    How do I position them (without overlapping one another) and also how to differentiate which lifebar is for which boss?

    Please see attached pic for reference

  • This is the best I can do. It works, but there must be a more elegant way to do it.

    http://eli0s.com/Tests/EnemyHealthBars.capx

  • eli0s

    link doesn't work? can you attach it instead?

  • I haven' even noticed that there was an attach option

    I don't understand why my ftp seems offline to you though, I am curious, is it perhaps an antivirus blocking the address, or a Geo-locational issue? Can you send me a pm and tell me from which country are you accesing the internet? I want to consider all possibilities before I check with the ftp provider.

  • eli0s

    I'm sorry I wasn't specific enough. Is there a way to make different enemies (meaning different objects inside a family) have their own individual lifebar but automatically being created top to bottom of right side.

    Like I have this setup (for example):

    Family BOSSES:

    object Boss1

    object Boss2

    object Boss3

    object Boss4

    object Boss5

    object Boss6

    object Boss7

    so in Layout 1, Boss1, Boss2 and Boss3 are the boss characters.

    So I checked the count of the family BOSSES object that are already existing in the layout (can't create the bosses since they are specific), then I don't know the next steps how to determine which lifebar is for which boss.

    Do take note though that I added a text family variable "BossName" that I set to their individual names for each boss at start of layout. I'm sure I will use that in this problem but I don't know how.

    My game is a platform scroller beat em up game. So each level has specific bosses.

    I'll send you a pm about your site.

    edit:

    can't send you a PM because "The requested users to be added do not exist." I don't have a clue what that problem means.

    Anyway, here's my intended PM to you

    "I don't think I can't access your site because of my antivirus because there will be a small pop-up message from it if it is blocking any sites. None pops up when I go to your site.

    I'm from the Philippines, but I'm not a Filipino by blood.

    Thanks"

  • The only thing I can think of is to create each enemy individually and set its family "Name" Variable to a "Name" variable on the lifebar object that you'll create right after. The problem is to find a way to align those bars dynamically. If you hard-code the creation process, then you'll have a particular order of creation to use in order to add a Y offset on each lifebar. This is the crude, brute force method of course...

    I am sure that using an array system will be most effective, but I can't begin to understand how arrays work, their commands are too cluttered for me

    Here is an updated capx, close to what I am describing above.

    http://www.eli0s.com/Tests/EnemyHealthBarsUpdated.capx

  • eli0s

    I'm sorry but I still can't access your site. I already turned off all antivirus/anti-spyware and similar programs

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