2020年9月3日

修改scratch3預載內容

 預載的內容在:scratch-gui/src/lib/default-project資料夾內。

index.js和project-data.js

把要加入的svg檔案拷貝到資料夾內,並使用 md5sum 檔案,算出編碼後的數字,例如:

md5sum osep.svg
48b6771e8ddcb19a37584bf4ce4df834  osep.svg 

把osep.svg重新命名為48b6771e8ddcb19a37584bf4ce4df834.svg

編輯index.js

在前面import中加入

import osep from '!raw-loader!./48b6771e8ddcb19a37584bf4ce4df834.svg';

在最後面加入

{
        id: '48b6771e8ddcb19a37584bf4ce4df834',
        assetType: 'ImageVector',
        dataFormat: 'SVG',
        data: encoder.encode(osep)
    },

 

編輯project-data.js

新增角色加入

{
                isStage: false,
                name: translator(messages.sprite, {index: 1}),
                variables: {},
                lists: {},
                broadcasts: {},
                blocks: {},
                currentCostume: 0,
                costumes: [
                    {
                        assetId: '48b6771e8ddcb19a37584bf4ce4df834',
                        name: translator(messages.costume, {index: 1}),
                        bitmapResolution: 1,
                        md5ext: '48b6771e8ddcb19a37584bf4ce4df834.svg',
                        dataFormat: 'svg',
                        rotationCenterX: 46,
                        rotationCenterY: 50
                    }
                ],
                sounds: [
                    {
                        assetId: '83c36d806dc92327b9e7049a565c6bff',
                        name: translator(messages.meow),
                        dataFormat: 'wav',
                        format: '',
                        rate: 22050,
                        sampleCount: 18688,
                        md5ext: '83c36d806dc92327b9e7049a565c6bff.wav'
                    }
                ],
                volume: 100,
                visible: true,
                x: 200,//角色座標
                y: -150,
                size: 50,//角色大小%
                direction: 90,
                draggable: false,
                rotationStyle: 'all around'
            }

 存檔,重新編譯程式。


src/lib/libraries/sprites.json記錄選取角色的資料, costumes.json圖檔資料

 storage.js

 

左上角超連結在src/playground/render-gui.jsx 

找到const onClickLogo =