Skip to content

Commit 5d214df

Browse files
CreativeCodingProjectsCreativeCodingProjects
authored andcommitted
added mouse pressed and mouse released
1 parent 66ae536 commit 5d214df

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

src/scene.js

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,31 @@
11
export default class Scene{
22

33
constructor(draw_function){
4-
this._draw_function = draw_function;
5-
this._click_function = function(){};
6-
this._mouse_moved_function = function(){};
7-
this._mouse_dragged_function = function(){};
8-
this._key_pressed_function = function(){};
9-
this._key_released_function = function(){};
4+
this._draw_function = draw_function;
5+
this._click_function = function(){};
6+
this._mouse_moved_function = function(){};
7+
this._mouse_dragged_function = function(){};
8+
this._mouse_pressed_function = function(){};
9+
this._mouse_released_function = function(){};
10+
this._key_pressed_function = function(){};
11+
this._key_released_function = function(){};
1012
vignettes.add_scene(this);
1113
}
1214

1315
draw(){
1416
this._draw_function();
1517
}
1618

17-
click(){
18-
this._click_function();
19-
}
20-
21-
mouse_moved(){
22-
this._mouse_moved_function();
23-
}
24-
25-
mouse_dragged(){
26-
this._mouse_dragged_function();
27-
}
28-
29-
key_pressed(){
30-
this._key_pressed_function();
19+
get click(){
20+
return this._click_function;
3121
}
3222

33-
key_released(keyboard_event){
34-
this._key_released_function();
23+
get mouse_pressed(){
24+
return this._mouse_pressed_function;
3525
}
3626

37-
get click(){
38-
return this._click_function;
27+
get mouse_released(){
28+
return this._mouse_released_function;
3929
}
4030

4131
get mouse_moved(){
@@ -58,6 +48,14 @@ export default class Scene{
5848
this._click_function = func;
5949
}
6050

51+
set mouse_pressed(func){
52+
this._mouse_pressed_function = func;
53+
}
54+
55+
set mouse_released(func){
56+
this._mouse_released_function = func;
57+
}
58+
6159
set mouse_moved(func){
6260
this._mouse_moved_function = func;
6361
}

src/vignettes.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ export default class Vignettes{
6363

6464
mouse_pressed(){
6565
this.scale_mouse();
66+
if(this._scenes.length > 0){
67+
this._scenes[this._current_scene].mouse_pressed();
68+
}
6669
}
6770

6871
mouse_released(){
72+
if(this._scenes.length > 0){
73+
this._scenes[this._current_scene].mouse_released();
74+
}
6975
}
7076

7177
mouse_moved(){

0 commit comments

Comments
 (0)