enable zoom in the camera

"
"
"
"
"
"
"
"
"
"
This commit is contained in:
Travis Shears 2026-05-14 10:51:28 +01:00
parent 00a999caf4
commit fe99c7a4a6
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
3 changed files with 105 additions and 41 deletions

View file

@ -6,34 +6,14 @@
:workflow { :workflow {
:open-tabs [ :open-tabs [
[ [
[
"/main/main.atlas"
:scene
]
[ [
"/main/main.collection" "/main/main.collection"
:scene :scene
] ]
[ [
"/main/player.tilesource" "/main/zoom.script"
:scene
]
[
"/main/player.script"
:code :code
] ]
[
"/game.project"
:cljfx-form-view
]
[
"/input/game.input_binding"
:cljfx-form-view
]
[
"/main/player.sprite"
:scene
]
] ]
] ]
:recent-files [ :recent-files [
@ -46,7 +26,15 @@
:text :text
] ]
[ [
"/main/player.tilesource" "/main/main.script"
:code
]
[
"/main/main.collection"
:text
]
[
"/main/player.sprite"
:scene :scene
] ]
[ [
@ -54,29 +42,41 @@
:scene :scene
] ]
[ [
"/main/player.sprite" "/main/player.tilesource"
:scene
]
[
"/input/game.input_binding"
:cljfx-form-view
]
[
"/main/main.script"
:code
]
[
"/game.project"
:cljfx-form-view
]
[
"/main/main.collection"
:scene :scene
] ]
[ [
"/main/player.script" "/main/player.script"
:code :code
] ]
[
"/main/zoom.render_script"
:code
]
[
"/builtins/render/default.render_script"
:code
]
[
"/builtins/render/default.render"
:cljfx-form-view
]
[
"/input/game.input_binding"
:cljfx-form-view
]
[
"/game.project"
:cljfx-form-view
]
[
"/main/zoom.script"
:code
]
[
"/main/main.collection"
:scene
]
] ]
} }
} }

View file

@ -2,7 +2,11 @@ name: "main"
scale_along_z: 0 scale_along_z: 0
embedded_instances { embedded_instances {
id: "camera" id: "camera"
data: "embedded_components {\n" data: "components {\n"
" id: \"zoom\"\n"
" component: \"/main/zoom.script\"\n"
"}\n"
"embedded_components {\n"
" id: \"camera\"\n" " id: \"camera\"\n"
" type: \"camera\"\n" " type: \"camera\"\n"
" data: \"aspect_ratio: 1.0\\n" " data: \"aspect_ratio: 1.0\\n"
@ -10,7 +14,7 @@ embedded_instances {
"near_z: -1.0\\n" "near_z: -1.0\\n"
"far_z: 1.0\\n" "far_z: 1.0\\n"
"orthographic_projection: 1\\n" "orthographic_projection: 1\\n"
"orthographic_mode: ORTHO_MODE_AUTO_COVER\\n" "orthographic_zoom: 2.0\\n"
"\"\n" "\"\n"
"}\n" "}\n"
"" ""

View file

@ -0,0 +1,60 @@
function init(self)
-- Add initialization code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 5 })
end
function final(self)
-- Add finalization code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function update(self, dt)
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
msg.post("@render:", "use_fixed_projection", { near = -1, far = 1, zoom = 5 })
end
function late_update(self, dt)
-- This function is called at the end of update cycle but before render
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function fixed_update(self, dt)
-- This function is called if 'Fixed Update Frequency' is enabled in the Engine section of game.project
-- Can be coupled with fixed updates of the physics simulation if 'Use Fixed Timestep' is enabled in
-- Physics section of game.project
-- Add update code here
-- Learn more: https://defold.com/manuals/script/
-- Remove this function if not needed
end
function on_message(self, message_id, message, sender)
-- Add message-handling code here
-- Learn more: https://defold.com/manuals/message-passing/
-- Remove this function if not needed
end
function on_input(self, action_id, action)
-- Add input-handling code here. The game object this script is attached to
-- must have acquired input focus:
--
-- msg.post(".", "acquire_input_focus")
--
-- All mapped input bindings will be received. Mouse and touch input will
-- be received regardless of where on the screen it happened.
-- Learn more: https://defold.com/manuals/input/
-- Remove this function if not needed
end
function on_reload(self)
-- Add reload-handling code here
-- Learn more: https://defold.com/manuals/hot-reload/
-- Remove this function if not needed
end