目录

API

Frame Rate

[h2]How do I change the frame rate of a quick game?

You are not advised to call the native method in the game engine to change the frame rate for a quick game. You are advised to use the qg.setPreferredFramesPerSecond API provided by Huawei to change the frame rate.

Account and Payment

[h2]Do I need to add other dependencies to the HTML5 file for HwFastappObject of APIs such as the sign-in and payment APIs in a game?

No. This object is a built-in object of Huawei Quick App Engine. After being packaged into an RPK, the game can run directly in Huawei Quick App Engine instead of browsers.

File

[h2]A success message is returned after I call the FileSystemManager.rmdir method to delete a directory. However, the cache is not cleared. What should I do?

Files are stored in different paths before and after sign-in. You are advised to perform operations on files after sign-in. Otherwise, target files may not be found.

[h2]When a runtime quick game uses FileSystemManager.readfile to read files, the message "file operate success" is displayed in the log, but no data is printed. What should I do?

When FileSystemManager.readFile is used to read files, if encoding is set to binary or not specified, and the returned data is of the ArrayBuffer type, the returned data cannot be directly printed in logs or converted using json.stringify. If encoding is set to utf8, you can use json.stringify to convert data and print it in logs.

[h2]What should I do if the message "no such file or directory" is displayed when FileSystemManager.rmdirSync is called?

Set the input parameter dirPath to the user directory path without a slash (/) as the suffix.

[h2]When FileSystemManager.copyFile is called to cache files, the message "no such file or directory" is displayed. What should I do?

If the source file used for calling the API is a temporary file, it cannot be cached. You need to call the FileSystemManager.saveFile API to save the temporary file to the local host, and then call the copyFile API to cache the file.

You should pass the URI in the response of the saveFile API to the source file path in the copyFile API.

The sample code is as follows:

var fileSystemManager = qg.getFileSystemManager();
var savedFilePath = '',
fileSystemManager.saveFile({
    tempFilePath: 'temp file path',
filePath: 'target file path',
    success : function(res) {
        console.log("saveFile success res = " + JSON.stringify(res));
savedFilePath = res;
    },
    fail : function(data) {
        console.log("saveFile fail " + JSON.stringify(data));
    },
    complete : function() {
        console.log("saveFile complete" );
    }
})
fileSystemManager.copyFile({
    srcPath : 'savedFilePath',  // Source file path. Set this parameter to the success callback address of the saveFile function.
    destPath : 'target path',
    success : function() {
        console.log("copy success" );
    },
    fail : function(data) {
        console.log("copy fail " + JSON.stringify(data));
    },
    complete : function() {
        console.log("copy complete" );
    }
})

[h2]What should I do if error message "{"errCode":6,"errMsg":"the maximum size of the file storage limit is exceeded"}" is displayed when the FileSystemManager.saveFile API is called?

The maximum size of the local data cache is 10 MB, and the maximum size of data that can be stored in the cache at a time is 1 MB. If the size exceeds 1 MB, the preceding error is reported. You are advised to control the size of data that can be cached at a time.

Switch Between Landscape and Portrait Modes

[h2]Do quick games provide an API for switching between landscape and portrait modes?

No. Currently, you can preset the screen orientation by setting the orientation attribute in the manifest file. The options are as follows: