Showing the changes to scripts/tutorials/entity_scripts (1 of 6 files). Show all
Unified · Split
| @@ -15,35 +15,35 @@ · 14 unmodified lines | |||
| 15 | 15 | ||
| 16 | function MidiSphere() { | 16 | function MidiSphere() { |
| 17 | _this = this; | 17 | _this = this; |
| 18 | this.clicked = false; | 18 | this.clicked = false; |
| 19 | return; | 19 | return; |
| 20 | } | 20 | } |
| 21 | 21 | ||
| 22 | MidiSphere.prototype = { | 22 | MidiSphere.prototype = { |
| 23 | preload: function(entityID) { | 23 | preload: function(entityID) { |
| 24 | this.entityID = entityID; | 24 | this.entityID = entityID; |
| 25 | Midi.midiNote.connect(function(eventData) { | 25 | Midi.midiNote.connect(function(eventData) { |
| 26 | print("MidiSphere.noteReceived: "+JSON.stringify(eventData)); | 26 | print("MidiSphere.noteReceived: "+JSON.stringify(eventData)); |
| 27 | Entities.editEntity(entityID, { color: { red: 2*eventData.note, green: 2*eventData.note, blue: 2*eventData.note} }); | 27 | Entities.editEntity(entityID, { color: { red: 2*eventData.note, green: 2*eventData.note, blue: 2*eventData.note} }); |
| 28 | }); | 28 | }); |
| 29 | print("MidiSphere.preload"); | 29 | print("MidiSphere.preload"); |
| 30 | }, | 30 | }, |
| 31 | unload: function(entityID) { | 31 | unload: function(entityID) { |
| 32 | print("MidiSphere.unload"); | 32 | print("MidiSphere.unload"); |
| 33 | }, | 33 | }, |
| 34 | 34 | ||
| 35 | clickDownOnEntity: function(entityID, mouseEvent) { | 35 | clickDownOnEntity: function(entityID, mouseEvent) { |
| 36 | print("MidiSphere.clickDownOnEntity"); | 36 | print("MidiSphere.clickDownOnEntity"); |
| 37 | if (this.clicked) { | 37 | if (this.clicked) { |
| 38 | Entities.editEntity(entityID, { color: { red: 0, green: 255, blue: 255} }); | 38 | Entities.editEntity(entityID, { color: { red: 0, green: 255, blue: 255} }); |
| 39 | this.clicked = false; | 39 | this.clicked = false; |
| 40 | Midi.playMidiNote(144, 64, 0); | 40 | Midi.playMidiNote(144, 64, 0); |
| 41 | } else { | 41 | } else { |
| 42 | Entities.editEntity(entityID, { color: { red: 255, green: 255, blue: 0} }); | 42 | Entities.editEntity(entityID, { color: { red: 255, green: 255, blue: 0} }); |
| 43 | this.clicked = true; | 43 | this.clicked = true; |
| 44 | Midi.playMidiNote(144, 64, 100); | 44 | Midi.playMidiNote(144, 64, 100); |
| 45 | } | 45 | } |
| 46 | } | 46 | } |
| 47 | 47 | ||
| 48 | }; | 48 | }; |
| 49 | 49 | ||