diff --git a/game.project b/game.project index d23f913..51c0367 100644 --- a/game.project +++ b/game.project @@ -1,6 +1,7 @@ [project] -title = My project +title = QRCode version = 0.1 +dependencies = https://github.com/defold/extension-camera/archive/master.zip [bootstrap] main_collection = /main/main.collectionc diff --git a/main/camera.atlas b/main/camera.atlas new file mode 100644 index 0000000..a72a2d8 --- /dev/null +++ b/main/camera.atlas @@ -0,0 +1,6 @@ +images { + image: "/main/images/logo.png" +} +margin: 0 +extrude_borders: 0 +inner_padding: 0 diff --git a/main/main.collection b/main/main.collection index 6667c3b..b380b79 100644 --- a/main/main.collection +++ b/main/main.collection @@ -23,9 +23,64 @@ embedded_instances { " }\n" "}\n" "" + position { + x: 120.02384 + y: 118.89577 + z: 1.0 + } + rotation { + x: 0.0 + y: 0.0 + z: 0.0 + w: 1.0 + } + scale3 { + x: 1.0 + y: 1.0 + z: 1.0 + } +} +embedded_instances { + id: "go" + data: "components {\n" + " id: \"script\"\n" + " component: \"/main/main.script\"\n" + " position {\n" + " x: 0.0\n" + " y: 0.0\n" + " z: 0.0\n" + " }\n" + " rotation {\n" + " x: 0.0\n" + " y: 0.0\n" + " z: 0.0\n" + " w: 1.0\n" + " }\n" + "}\n" + "embedded_components {\n" + " id: \"sprite\"\n" + " type: \"sprite\"\n" + " data: \"tile_set: \\\"/main/camera.atlas\\\"\\n" + "default_animation: \\\"logo\\\"\\n" + "material: \\\"/builtins/materials/sprite.material\\\"\\n" + "blend_mode: BLEND_MODE_ALPHA\\n" + "\"\n" + " position {\n" + " x: 0.0\n" + " y: 0.0\n" + " z: 0.0\n" + " }\n" + " rotation {\n" + " x: 0.0\n" + " y: 0.0\n" + " z: 0.0\n" + " w: 1.0\n" + " }\n" + "}\n" + "" position { x: 640.0 - y: 340.0 + y: 360.0 z: 0.0 } rotation { diff --git a/main/main.script b/main/main.script new file mode 100644 index 0000000..d30a85c --- /dev/null +++ b/main/main.script @@ -0,0 +1,53 @@ + +function init(self) + local logosize = 128 + local screen_width = sys.get_config("display.width", 600) + local screen_height = sys.get_config("display.height", 800) + local scale_width = screen_width / logosize + local scale_height = screen_height / logosize + + go.set("#sprite", "scale", vmath.vector3(scale_width, scale_height, 1) ) + + if camera ~= nil then + + local sysinfo = sys.get_sys_info() + + local quality = camera.CAPTURE_QUALITY_HIGH + local type = camera.CAMERA_TYPE_FRONT + if sysinfo.system_name == 'iPhone OS' then + type = camera.CAMERA_TYPE_BACK + quality = camera.CAPTURE_QUALITY_MEDIUM + end + + if camera.start_capture(type, quality) then + self.cameraframe = camera.get_frame() + self.camerainfo = camera.get_info() + print("Initialized camera") + pprint(self.camerainfo) + + self.cameratextureheader = {width=self.camerainfo.width, + height=self.camerainfo.height, + type=resource.TEXTURE_TYPE_2D, + format=resource.TEXTURE_FORMAT_RGB, + num_mip_maps=1 } + end + else + print("could not start camera capture") + end +end + +function final(self) + if self.cameraframe ~= nil then + camera.stop_capture() + end +end + + +function update(self, dt) + if self.cameraframe then + local pathmodelcamera = go.get("#sprite", "texture0") + resource.set_texture(pathmodelcamera, self.cameratextureheader, self.cameraframe) + end + + +end