{"id":33169561,"url":"https://github.com/bmarwane/phaser.healthbar","last_synced_at":"2025-11-20T19:01:01.153Z","repository":{"id":112862271,"uuid":"41646435","full_name":"bmarwane/phaser.healthbar","owner":"bmarwane","description":null,"archived":false,"fork":false,"pushed_at":"2018-12-04T11:40:20.000Z","size":770,"stargazers_count":70,"open_issues_count":3,"forks_count":21,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-05-17T12:33:10.083Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmarwane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2015-08-30T23:29:59.000Z","updated_at":"2021-07-19T23:44:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"efdf3735-92b3-4d26-9060-3bf9045890f7","html_url":"https://github.com/bmarwane/phaser.healthbar","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bmarwane/phaser.healthbar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwane%2Fphaser.healthbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwane%2Fphaser.healthbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwane%2Fphaser.healthbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwane%2Fphaser.healthbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmarwane","download_url":"https://codeload.github.com/bmarwane/phaser.healthbar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmarwane%2Fphaser.healthbar/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":285494607,"owners_count":27181443,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-11-20T02:00:05.334Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-11-16T01:00:33.531Z","updated_at":"2025-11-20T19:01:01.142Z","avatar_url":"https://github.com/bmarwane.png","language":"JavaScript","funding_links":[],"categories":["Uncategorized"],"sub_categories":["Uncategorized"],"readme":"# Phaser.HealthBar\n\nAn attempt to create a simple and customizable health bar for Phaser.js games.\n\nI made a tutorial in French that explain how to create this health bar from scratch, you can check it out [here](http://apprendre-le-js.com/phaser-js-healthbar-tutorial/ \"apprendre-le-js.com healthbar tutorial\").\n\n## Demo\n\n[Demo](http://apprendre-le-js.com/tuto_examples/healthbar/4/)\n\n## Usage\n\n### 1 - Import HealthBar file\n\nIf you are using a CommonJS implementation (Browserify) :\n\n```javascript\nvar HealthBar = require('path/to/HealthBar.js');\n```\n\nif not, just include the HealthBar.standalone.js in the html file.\nexample : \n``` html\n\u003cscript src=\"path/to/HealthBar.standalone.js\"\u003e\u003c/script\u003e\n```\n\n### 2 - create a HealthBar :\n\nin the game/state create function instantiate a HealthBar like this: \n\n```javascript\ncreate: function() {\t\n\tvar barConfig = {x: 200, y: 100};\n\tthis.myHealthBar = new HealthBar(this.game, barConfig);\n}\n```\n## Configuration\n\n![](https://raw.githubusercontent.com/bmarwane/phaser.healthbar/master/phaser.healthbar.config.png)\n\n- **width**\n- **height**\n- **x:** initial x position \n- **y:** initial y position\n- **bg.color:** background color\n- **bar.color:** color of the actual bar\n- **animationDuration:** control the animation when the bar value is changed\n- **flipped:** if true the bar will change size from left to right\n\nthis is the default configuration : \n```javascript\n{\n    width: 250,\n    height: 40,\n    x: 0,\n    y: 0,\n    bg: {\n      color: '#651828'\n    },\n    bar: {\n      color: '#FEFF03'\n    },\n    animationDuration: 200,\n    flipped: false\n  };\n```\n\n## Methods\n\n### setPercent(value):\n\nset the width of the bar to the passed percentage value.\n\n**example:**\n\n```javascript\n this.myHealthBar = new HealthBar(this.game, {x: 200, y: 200, width: 120});\n\n // the width will be set to 50% of the actual size so the new value will be 60\n this.myHealthBar.setPercent(50); \n```\n \n### setPosition(x, y): \n change the position of the bar to the provided coordinates.\n \n### setBarColor(newColor)\n\nchange the bar color, use the hex color format.\nexample :\n```javascript\nthis.myHealthBar.setBarColor('#fc9802');\n```\n\n### setFixedToCamera(fixedToCamera);\n fixedToCamera must be true or false value (boolean type).\n method allows fixed to camera.\n\n### setToGroup(group);\n add bar to some group\n\n### removeFromGroup();\n remove bar from current group and add back to game.world group\n\n### kill();\n will kill the HealthBar.\n\n# License\n\nPhaser.HealthBar is released under the [MIT License](https://opensource.org/licenses/MIT).\n \n \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwane%2Fphaser.healthbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmarwane%2Fphaser.healthbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmarwane%2Fphaser.healthbar/lists"}