enable zoom in the camera
" " " " " " " " " "
This commit is contained in:
parent
00a999caf4
commit
fe99c7a4a6
3 changed files with 105 additions and 41 deletions
|
|
@ -6,34 +6,14 @@
|
|||
:workflow {
|
||||
:open-tabs [
|
||||
[
|
||||
[
|
||||
"/main/main.atlas"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
"/main/main.collection"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
"/main/player.tilesource"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
"/main/player.script"
|
||||
"/main/zoom.script"
|
||||
:code
|
||||
]
|
||||
[
|
||||
"/game.project"
|
||||
:cljfx-form-view
|
||||
]
|
||||
[
|
||||
"/input/game.input_binding"
|
||||
:cljfx-form-view
|
||||
]
|
||||
[
|
||||
"/main/player.sprite"
|
||||
:scene
|
||||
]
|
||||
]
|
||||
]
|
||||
:recent-files [
|
||||
|
|
@ -46,7 +26,15 @@
|
|||
:text
|
||||
]
|
||||
[
|
||||
"/main/player.tilesource"
|
||||
"/main/main.script"
|
||||
:code
|
||||
]
|
||||
[
|
||||
"/main/main.collection"
|
||||
:text
|
||||
]
|
||||
[
|
||||
"/main/player.sprite"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
|
|
@ -54,29 +42,41 @@
|
|||
:scene
|
||||
]
|
||||
[
|
||||
"/main/player.sprite"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
"/input/game.input_binding"
|
||||
:cljfx-form-view
|
||||
]
|
||||
[
|
||||
"/main/main.script"
|
||||
:code
|
||||
]
|
||||
[
|
||||
"/game.project"
|
||||
:cljfx-form-view
|
||||
]
|
||||
[
|
||||
"/main/main.collection"
|
||||
"/main/player.tilesource"
|
||||
:scene
|
||||
]
|
||||
[
|
||||
"/main/player.script"
|
||||
: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
|
||||
]
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,11 @@ name: "main"
|
|||
scale_along_z: 0
|
||||
embedded_instances {
|
||||
id: "camera"
|
||||
data: "embedded_components {\n"
|
||||
data: "components {\n"
|
||||
" id: \"zoom\"\n"
|
||||
" component: \"/main/zoom.script\"\n"
|
||||
"}\n"
|
||||
"embedded_components {\n"
|
||||
" id: \"camera\"\n"
|
||||
" type: \"camera\"\n"
|
||||
" data: \"aspect_ratio: 1.0\\n"
|
||||
|
|
@ -10,7 +14,7 @@ embedded_instances {
|
|||
"near_z: -1.0\\n"
|
||||
"far_z: 1.0\\n"
|
||||
"orthographic_projection: 1\\n"
|
||||
"orthographic_mode: ORTHO_MODE_AUTO_COVER\\n"
|
||||
"orthographic_zoom: 2.0\\n"
|
||||
"\"\n"
|
||||
"}\n"
|
||||
""
|
||||
|
|
|
|||
60
defold_game/main/zoom.script
Normal file
60
defold_game/main/zoom.script
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue