Added proper hit test with rotation and pivoting

This commit is contained in:
2026-05-20 20:56:25 +01:00
parent 75b1bc5dbd
commit 6ff16e3db4
7 changed files with 181 additions and 35 deletions
+4 -2
View File
@@ -14,10 +14,12 @@ App.localize(:en, :btn_text, "Click %{name}!")
text = ElementText.new :btn_text, default_font, 0xFFFF00, {name: "Me"}, position: {x: 50, y: 50}, z: 1, click_through: true, alpha: 1
rect = ElementRect.new 100, 25, 0xFF0000, position: {x: 50, y: 50}, z: 0, rotation: 60, scale: { x: 1.5, y: 1 }, alpha: 0.4
rect = ElementRect.new 100, 25, 0xFF0000, position: {x: 50, y: 50}, z: 0, rotation: 60, pivot: {x: 0.5, y: 0.5}, scale: { x: 1, y: 1 }, alpha: 0.4
image_element = ElementImage.new bg_animation, position: {x: 0, y: 0}, z: -1, click_through: true, alpha: 1
pp text, rect, image_element
rect.on_click do
rect.color = rect.color == 0xFF0000 ?
0x00FF00 :
@@ -47,7 +49,7 @@ main_scene.on_update do |delta_time|
pp App.text_input if App.text_input != ""
next unless App.pressed?(:press)
next unless App.down?(:press)
pp "#{App.pressed?(:press)}, #{App.down?(:press)}, #{App.released?(:press)}"