rubysketch 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +8 -0
- data/VERSION +1 -1
- data/lib/rubysketch/sprite.rb +47 -7
- data/rubysketch.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5385034a66ab2a3bba10f16e08dc828f6f8dd4d3dc9f8425a4d009e46945e9e7
|
4
|
+
data.tar.gz: 60027fb7618e84373d0943d5a091548e5d503e6234f61344d57de8a2d9805714
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c596d721b9d2965fcb32f7cd1b28e1d76120a71283c11f11be37b983988ac31cfb350f46c9b7441efecb66260c39762cbe6ef4b3a8292b5c89445f7b20154b
|
7
|
+
data.tar.gz: eaa2be7d0033d6f7c37d4252cd45acfbdc6d6567139f5e87627bdc9260e80d827b52ffddde6650fac30241e289b6cb328f21a21f62d5a147af04d74a19280334
|
data/ChangeLog.md
CHANGED
@@ -1,6 +1,14 @@
|
|
1
1
|
# rubysketch ChangeLog
|
2
2
|
|
3
3
|
|
4
|
+
## [v0.5.9] - 2023-05-19
|
5
|
+
|
6
|
+
- Add Sprite#clickCount()
|
7
|
+
- Add Sprite#from_screen() and to_screen()
|
8
|
+
- Sprite#update returns nil
|
9
|
+
- Sprite#center includes z
|
10
|
+
|
11
|
+
|
4
12
|
## [v0.5.8] - 2023-05-18
|
5
13
|
|
6
14
|
- Dispatch pointer events only to the topmost sprite
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.9
|
data/lib/rubysketch/sprite.rb
CHANGED
@@ -142,7 +142,7 @@ module RubySketch
|
|
142
142
|
# @return [Vector] center position
|
143
143
|
#
|
144
144
|
def center()
|
145
|
-
Vector.new(x + w / 2, y + h / 2)
|
145
|
+
Vector.new(x + w / 2, y + h / 2, z)
|
146
146
|
end
|
147
147
|
|
148
148
|
# Sets the center position of the sprite.
|
@@ -157,7 +157,7 @@ module RubySketch
|
|
157
157
|
#
|
158
158
|
def center=(arg)
|
159
159
|
x, y = *(arg.is_a?(Vector) ? arg.getInternal__.to_a : arg)
|
160
|
-
self.pos = [x - w / 2, y - h / 2]
|
160
|
+
self.pos = [x - w / 2, y - h / 2, z]
|
161
161
|
self.center
|
162
162
|
end
|
163
163
|
|
@@ -492,6 +492,26 @@ module RubySketch
|
|
492
492
|
alias rest restitution
|
493
493
|
alias rest= restitution=
|
494
494
|
|
495
|
+
# Converts a vector from the screen coordinate
|
496
|
+
#
|
497
|
+
# @param [Vector] vec screen coordinate vector
|
498
|
+
#
|
499
|
+
# @return [Vector] sprite coordinate vector
|
500
|
+
#
|
501
|
+
def from_screen(vec)
|
502
|
+
@view__.from_parent(vec.getInternal__).toVector
|
503
|
+
end
|
504
|
+
|
505
|
+
# Converts a vector to the screen coordinate
|
506
|
+
#
|
507
|
+
# @param [Vector] vec sprite coordinate vector
|
508
|
+
#
|
509
|
+
# @return [Vector] screen coordinate vector
|
510
|
+
#
|
511
|
+
def to_screen(vec)
|
512
|
+
@view__.to_parent(vec.getInternal__).toVector
|
513
|
+
end
|
514
|
+
|
495
515
|
# Returns the x-position of the mouse in the sprite coordinates.
|
496
516
|
#
|
497
517
|
# @return [Numeric] x position
|
@@ -532,6 +552,14 @@ module RubySketch
|
|
532
552
|
@view__.mouseButton
|
533
553
|
end
|
534
554
|
|
555
|
+
# Returns the mouse button click count on the sprite.
|
556
|
+
#
|
557
|
+
# @return [Numeric] click count
|
558
|
+
#
|
559
|
+
def clickCount()
|
560
|
+
@view__.clickCount
|
561
|
+
end
|
562
|
+
|
535
563
|
# Returns the touch objects touched on the sprite.
|
536
564
|
#
|
537
565
|
# @return [Array<Touch>] touches
|
@@ -551,6 +579,7 @@ module RubySketch
|
|
551
579
|
#
|
552
580
|
def update(&block)
|
553
581
|
@view__.update = block
|
582
|
+
nil
|
554
583
|
end
|
555
584
|
|
556
585
|
# Defines draw block.
|
@@ -756,23 +785,27 @@ module RubySketch
|
|
756
785
|
((@pointersPressed + @pointersReleased) & [LEFT, RIGHT, CENTER]).last
|
757
786
|
end
|
758
787
|
|
788
|
+
def clickCount()
|
789
|
+
clicked? ? 1 : 0
|
790
|
+
end
|
791
|
+
|
759
792
|
def on_update(e)
|
760
793
|
@update&.call
|
761
794
|
end
|
762
795
|
|
763
796
|
def on_pointer_down(e)
|
764
797
|
updatePointerStates e, true
|
765
|
-
@pointerDownStartPos = @pointerPos
|
798
|
+
@pointerDownStartPos = to_screen @pointerPos
|
766
799
|
(@touchStarted || @mousePressed)&.call if e.view_index == 0
|
767
800
|
end
|
768
801
|
|
769
802
|
def on_pointer_up(e)
|
770
803
|
updatePointerStates e, false
|
771
|
-
|
772
|
-
|
773
|
-
@mouseClicked&.call if
|
774
|
-
@pointerDownStartPos = nil
|
804
|
+
if e.view_index == 0
|
805
|
+
(@touchEnded || @mouseReleased)&.call
|
806
|
+
@mouseClicked&.call if clicked?
|
775
807
|
end
|
808
|
+
@pointerDownStartPos = nil
|
776
809
|
@pointersReleased.clear
|
777
810
|
end
|
778
811
|
|
@@ -819,6 +852,13 @@ module RubySketch
|
|
819
852
|
end
|
820
853
|
end
|
821
854
|
|
855
|
+
def clicked?()
|
856
|
+
return false unless @pointerPos && @pointerDownStartPos
|
857
|
+
[to_screen(@pointerPos), @pointerDownStartPos]
|
858
|
+
.map {|pos| Rays::Point.new pos.x, pos.y, 0}
|
859
|
+
.then {|pos, startPos| (pos - startPos).length < 3}
|
860
|
+
end
|
861
|
+
|
822
862
|
end# SpriteView
|
823
863
|
|
824
864
|
|
data/rubysketch.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.add_runtime_dependency 'beeps', '~> 0.1.37'
|
34
34
|
s.add_runtime_dependency 'rays', '~> 0.1.37'
|
35
35
|
s.add_runtime_dependency 'reflexion', '~> 0.1.39'
|
36
|
-
s.add_runtime_dependency 'processing', '~> 0.5.
|
36
|
+
s.add_runtime_dependency 'processing', '~> 0.5.10'
|
37
37
|
|
38
38
|
s.add_development_dependency 'rake'
|
39
39
|
s.add_development_dependency 'test-unit'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysketch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-05-
|
11
|
+
date: 2023-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.
|
89
|
+
version: 0.5.10
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.
|
96
|
+
version: 0.5.10
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|