rubysketch 0.5.25 → 0.5.26
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +5 -0
- data/VERSION +1 -1
- data/lib/rubysketch/context.rb +3 -3
- data/lib/rubysketch/sprite.rb +18 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c49c9860053850965c49ba550e222dbbc31dd41c26ed5a0e3ccba96cc70f30
|
4
|
+
data.tar.gz: f6d5e3eff58ce12340eccf50bb9dc2d21f19403ad54828890fe49c19428a9f30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbab1d6a12f52dbbef8c66be6dc86fccfb5da9c63807ea579ca4b61042d4e8df0fa223f533eb2ef6505054b4d4e0cfe812e9eadebd6926ae65ec0a22243c0760
|
7
|
+
data.tar.gz: a942e138e2350c873a148cf2ec17f58c6aded29685956f00c35eb50583403d3771dfe84b8ea3d303c01c0026e93fdd079716b47699f21d4a86189de378f96234
|
data/ChangeLog.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.26
|
data/lib/rubysketch/context.rb
CHANGED
@@ -44,7 +44,7 @@ module RubySketch
|
|
44
44
|
def setInterval(seconds = 0, *args, id: nextTimerID__, now: false, &block)
|
45
45
|
return unless block
|
46
46
|
time = Time.now.to_f
|
47
|
-
block.call
|
47
|
+
block.call(*args) if now
|
48
48
|
setInterval__ id, time, seconds, args, &block
|
49
49
|
end
|
50
50
|
|
@@ -59,7 +59,7 @@ module RubySketch
|
|
59
59
|
now, nextTime = Time.now.to_f, startTime + seconds
|
60
60
|
nextTime = now if nextTime < now
|
61
61
|
setTimeout__ id, nextTime do
|
62
|
-
block.call
|
62
|
+
block.call(*args)
|
63
63
|
setInterval__ id, nextTime, seconds, args, &block
|
64
64
|
end
|
65
65
|
end
|
@@ -91,7 +91,7 @@ module RubySketch
|
|
91
91
|
@timers__.delete_if do |id, (time, args, block)|
|
92
92
|
(now >= time).tap {|fire| @firingTimers__[id] = [block, args] if fire}
|
93
93
|
end
|
94
|
-
@firingTimers__.each {|_, (block, args)| block.call
|
94
|
+
@firingTimers__.each {|_, (block, args)| block.call(*args)}
|
95
95
|
end
|
96
96
|
|
97
97
|
# Animate with easing functions
|
data/lib/rubysketch/sprite.rb
CHANGED
@@ -879,6 +879,7 @@ module RubySketch
|
|
879
879
|
@sprite = sprite
|
880
880
|
super(*a, **k, &b)
|
881
881
|
|
882
|
+
@error = nil
|
882
883
|
@pointer = nil
|
883
884
|
@pointerPrev = nil
|
884
885
|
@pointersPressed = []
|
@@ -915,7 +916,7 @@ module RubySketch
|
|
915
916
|
end
|
916
917
|
|
917
918
|
def on_update(e)
|
918
|
-
@update
|
919
|
+
call_block @update
|
919
920
|
end
|
920
921
|
|
921
922
|
def on_pointer_down(e)
|
@@ -923,8 +924,8 @@ module RubySketch
|
|
923
924
|
updatePointersPressedAndReleased e, true
|
924
925
|
@pointerDownStartPos = to_screen @pointer.pos
|
925
926
|
if e.view_index == 0
|
926
|
-
@mousePressed
|
927
|
-
@touchStarted
|
927
|
+
call_block @mousePressed if e.any? {|p| p.id == @pointer.id}
|
928
|
+
call_block @touchStarted
|
928
929
|
end
|
929
930
|
end
|
930
931
|
|
@@ -933,10 +934,10 @@ module RubySketch
|
|
933
934
|
updatePointersPressedAndReleased e, false
|
934
935
|
if e.view_index == 0
|
935
936
|
if e.any? {|p| p.id == @pointer.id}
|
936
|
-
@mouseReleased
|
937
|
-
@mouseClicked
|
937
|
+
call_block @mouseReleased
|
938
|
+
call_block @mouseClicked if mouseClicked?
|
938
939
|
end
|
939
|
-
@touchEnded
|
940
|
+
call_block @touchEnded
|
940
941
|
end
|
941
942
|
@pointerDownStartPos = nil
|
942
943
|
@pointersReleased.clear
|
@@ -946,8 +947,8 @@ module RubySketch
|
|
946
947
|
updatePointerStates e
|
947
948
|
if e.view_index == 0
|
948
949
|
mouseMoved = e.drag? ? @mouseDragged : @mouseMoved
|
949
|
-
mouseMoved
|
950
|
-
@touchMoved
|
950
|
+
call_block mouseMoved if e.any? {|p| p.id == @pointer.id}
|
951
|
+
call_block @touchMoved
|
951
952
|
end
|
952
953
|
end
|
953
954
|
|
@@ -957,12 +958,12 @@ module RubySketch
|
|
957
958
|
|
958
959
|
def on_contact_begin(e)
|
959
960
|
v = e.view
|
960
|
-
@contact
|
961
|
+
call_block @contact, v.sprite, e.action if @contact && v.respond_to?(:sprite)
|
961
962
|
end
|
962
963
|
|
963
964
|
def will_contact?(v)
|
964
965
|
return true unless @will_contact && v.respond_to?(:sprite)
|
965
|
-
@will_contact
|
966
|
+
call_block @will_contact, v.sprite
|
966
967
|
end
|
967
968
|
|
968
969
|
private
|
@@ -1002,6 +1003,13 @@ module RubySketch
|
|
1002
1003
|
.then {|pos, startPos| (pos - startPos).length < 3}
|
1003
1004
|
end
|
1004
1005
|
|
1006
|
+
def call_block(block, *args)
|
1007
|
+
block.call(*args) if block && !@error
|
1008
|
+
rescue Exception => e
|
1009
|
+
@error = e
|
1010
|
+
$stderr.puts e.full_message
|
1011
|
+
end
|
1012
|
+
|
1005
1013
|
end# SpriteView
|
1006
1014
|
|
1007
1015
|
|
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.26
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- xordog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: xot
|