1 decade ago by bitmapshades
So far I'm unable to resolve how to invoke the draw() function from my player inventory class and display the panel which would be the ideal solution.
So now I'm doing the drawing using my HUD entity I wrote, but I'm having issues trying to simplify drawing inventory slots from this which is quite verbose:
to the following which is cleaner but throws an object undefined error in the console. The console traces the object props fine though.
So now I'm doing the drawing using my HUD entity I wrote, but I'm having issues trying to simplify drawing inventory slots from this which is quite verbose:
// hud.js drawItemSlot: function(string){ ig.system.context.beginPath(); switch(string){ case('head'): ig.system.context.rect(this.slots.head.x, this.slots.head.y, this.slots.head.w, this.slots.head.h); break; case('chest'): ig.system.context.rect(this.slots.chest.x, this.slots.chest.y, this.slots.chest.w, this.slots.chest.h); break; case('weapon'): ig.system.context.rect(this.slots.weapon.x, this.slots.weapon.y, this.slots.weapon.w, this.slots.weapon.h); break; case('comms'): ig.system.context.rect(this.slots.chest.x, this.slots.chest.y, this.slots.chest.w, this.slots.chest.h); break; } ig.system.context.closePath(); ig.system.context.fill(); },
to the following which is cleaner but throws an object undefined error in the console. The console traces the object props fine though.
// generates an error when passing an object in from a function called drawItemSlot: function(slot){ ig.system.context.beginPath(); ig.system.context.rect(slot.x, slot.y. slot.w, slot.h); ig.system.context.closePath(); ig.system.context.fill(); },