1 decade ago by bitmapshades
I wrote this plugin for a quest icon that works like quest icons in MMO games where the icon moves with the NPC then moves to the next NPC in the quest chain. Ttrying to refine it so that I can make it portable for different quests. Maybe someone on these boards can see if there's a way to do that?
ig.module( 'game.entities.questicon' ) .requires( 'impact.entity' ) .defines(function(){ EntityQuesticon = ig.Entity.extend({ animSheet: new ig.AnimationSheet( 'media/quest-sprite.png', 30, 30 ), size: {x: 30, y: 30}, offset: {x: 0, y: 0}, amount: 1, type: ig.Entity.TYPE.NONE, checkAgainst: ig.Entity.TYPE.A, // Check against friendly collides: ig.Entity.COLLIDES.NEVER, init: function( x, y, settings ) { this.parent( x, y, settings ); // Add the animations this.addAnim('idle', 1, [8]); this.addAnim('fadein', 0.2, [1, 2, 3, 4, 5, 6, 7, 8]); this.addAnim('fadeout', 0.2, [8, 7, 6, 5, 4, 3, 2, 1]); //this.timer = new ig.Timer(10); }, update: function() { var target; // if mission accepted switch(ig.game.mission.stage){ case(10): this.pos.x = -99; this.pos.y = -99; break; case(20): this.kill(); break; case(30): this.kill(); break; case(40): this.kill(); break; } switch(ig.game.state){ case('play'): // if entity exists move with target position target = ig.game.getEntityByName('Miss Robbins'); if(target && ig.game.mission.stage < 10){ this.pos.x = target.pos.x; this.pos.y = target.pos.y - 30; } target = ig.game.getEntityByName('Lieutenant Biggs'); if(target && ig.game.mission.stage < 20){ this.pos.x = target.pos.x; this.pos.y = target.pos.y - 30; } this.currentAnim = this.anims.idle; break; default: break; } this.parent(); }, }); });