Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Clase que construye un LifeBar
- * @class LifeBar
- * @constructors
- * @this {LifeBar}
- * @param {Number} x Posicion X en el que se encuentra
- * @param {Number} y Posicion Y en el que se encuentra
- * @param {Number} width Anchura del LifeBar
- * @param {Number} height Altura del LifeBar
- * @param {Number} initLife valor de la vida inicial
- * @returns {LifeBar}
- */
- function LifeBar(x, y, width, height, initLife) {
- /* * Posicion X en el que se encuentra. Por defecto 0.
- * @type Number
- */
- this.x = (x == null) ? 0 : x;
- /* * Posicion Y en el que se encuentra. Por defecto 0.
- * @type Number
- */
- this.y = (y == null) ? 0 : y;
- /* * Anchura del TextArea. Por defecto 0.
- * @type Number
- */
- this.width = (width == null) ? 0 : width;
- /**
- * Altura del TextArea Por defecto el tamano de la anchura.
- * @type Number
- */
- this.height = (height == null) ? this.width : height;
- /**
- * Imagen de la barra de vida que lo saca de una variable global llamada imgLife
- * @type imgLife
- */
- this.img = imgLife;
- /**
- * Anchura de la imagen, es la vida actual que mostrara respecto la barra entera de vida
- * @type Number
- */
- this.imgwidth = width;
- /**
- * Vida inicial
- * @type Number
- */
- this.initLife = initLife;
- /**
- * Metodo para actualizar la barra vida
- * @param {Number} life vida actual
- * @returns {void}
- */
- this.updateLife = function(life) {
- if (life >= 0) {
- this.imgwidth = life / this.initLife * this.width;
- } else {
- this.imgwidth = 0;
- }
- }
- /**
- * Metodo que updatea la posicion de la barra de vida
- * @param {Number} x nueva posicion x
- * @param {Number} y nueva posicion y
- * @returns {void}
- */
- this.updatePosition = function(x, y) {
- this.x = (x == null) ? 0 : x;
- this.y = (y == null) ? 0 : y;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment