• Home
Name Date Size #Lines LOC

..--

AppScope/12-May-2024-3633

entry/12-May-2024-1,2411,026

screenshot/devices/12-May-2024-

.gitignoreD12-May-2024100 77

README.mdD12-May-20241.5 KiB3618

README_zh.mdD12-May-20241.8 KiB3719

build-profile.json5D12-May-20241 KiB4341

hvigorfile.jsD12-May-2024168 21

package.jsonD12-May-2024374 1918

README.md

1# Puzzle Game
2
3### Introduction
4
5This puzzle game app is developed based on the **\<Grid>** component. It uses the `Image` and `MediaLibrary` APIs to obtain and crop images. Below shows the sample app.
6
7![running](screenshot/devices/change.jpeg)
8
9### Concepts
10
11`ImagePacker`: a class that provides APIs to pack images. Before calling any API in `ImagePacker`, you must use `createImagePacker` to create an `ImagePacker` instance.
12
13`MediaLibrary`: a class that provides APIs to access and modify media data such as audios, videos, images, and documents.
14
15### Required Permissions
16
17ohos.permission.READ_MEDIA
18
19### Usage
20
211. The sample app reads the image files on the local device and displays the first image it obtains. If there is no image on the local device, a blank is displayed.
22
232. Touch **Start**, and the countdown begins. If you fail to finish the puzzle within the specified time, the game ends. You can touch **Restart** to play the game again.
24
253. When the game is in progress, you can touch any image around the gray grid to swap the position of the image and highlighted grid cell, until you get a complete image.
26
274. When the game is not in progress, you can touch the large image on the top and select another image for the game.
28
29### Constraints
30
311. This sample can only be run on standard-system devices.
32
332. This sample demonstrates the stage model, which supports only API version 9.
34
353. This sample requires DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022) to compile and run.
36

README_zh.md

1# 拼图
2
3### 简介
4
5拼图Demo是基于Grid组件进行开发,通过image (图片处理)和medialibrary (媒体库管理)接口实现获取图片,以及图片裁剪分割。实现效果如下:
6
7![running](screenshot/devices/change.jpeg)
8
9### 相关概念
10
11ImagePacker:图片打包器类,用于图片压缩和打包。在调用ImagePacker的方法前,需要先通过createImagePacker构建一个ImagePacker实例。
12
13媒体库管理:获取媒体库的实例,用于访问和修改用户等个人媒体数据信息(如音频、视频、图片、文档等)。
14
15### 相关权限
16
17读取公共媒体文件权限:[ohos.permission.READ_MEDIA](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)
18
19读取用户媒体文件中的地理位置信息 :[ohos.permission.MEDIA_LOCATION](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/security/permission-list.md)
20
21### 使用说明
22
231.使用预置相机拍照后启动应用,应用首页会读取设备内的图片文件并展示获取到的第一个图片,没有图片时图片位置显示空白。
24
252.点击Start开始后,时间开始倒计时,在规定时间内未完成拼图则游戏结束。在游戏中,玩家点击Restart进行游戏重置。
26
273.点击开始游戏后,玩家可以根据上方的大图,点击灰格周围的图片移动,点击后图片和灰格交换位置,最终拼成完整的图片。
28
294.不在游戏中时,玩家可以点击上方大图,选择自定义图片来进行拼图游戏。
30
31### 约束与限制
32
331.本示例仅支持标准系统上运行。
34
352.本示例为Stage模型,从API version 9开始支持。
36
373.本示例需要使用DevEco Studio 3.0 Beta4 (Build Version: 3.0.0.992, built on July 14, 2022)才可编译运行。