Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- update: function() {
- // Update all entities and backgroundMaps
- if( ig.input.pressed('select')) {
- // Do this once
- if(this.selectBox !== null){
- var i,creatures;
- creatures = this.getEntitiesByType("EntityCreature");
- // clear all other selections
- for(i=0;i<creatures.length;i++){
- if(creatures[i].selected){
- creatures[i].deselect();
- }
- }
- }
- console.log("Startpos");
- this.selectBox = {};
- this.selectBox.startx = this.selectBox.x = ig.input.mouse.x;
- this.selectBox.starty = this.selectBox.y = ig.input.mouse.y;
- console.log("Started:",this.selectBox);
- }else if(!!ig.input.state('select') && this.selectBox !== null){
- if(!(this.selectBox.x === ig.input.mouse.x && this.selectBox.y === ig.input.mouse.y)){
- console.log("drawing select?, setting selectBox");
- this.selectBox.x = ig.input.mouse.x;
- this.selectBox.y = ig.input.mouse.y;
- }
- }else{
- if (!ig.input.state('select') &&
- this.selectBox !== null &&
- !(this.selectBox.x === this.selectBox.startx && this.selectBox.y === this.selectBox.starty)
- ){ // false
- this.selectBox.x = ig.input.mouse.x;
- this.selectBox.y = ig.input.mouse.y;
- ig.system.context.strokeStyle = '#f00'; // red
- ig.system.context.lineWidth = 1;
- ig.system.context.strokeRect (
- this.selectBox.startx
- this.selectBox.starty
- this.selectBox.x
- this.selectBox.y
- );
- console.log("ended:",this.selectBox);
- throw Exception("tesT");
- }
- //console.log("set selectBox null in final");
- this.selectBox = null;
- }
- this.parent();
- // Add your own, additional update code here
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement