mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-07 11:34:00 -04:00
Fix new project creation (#256)
* Fix new project creation * Fix new project creation * const -> var
This commit is contained in:
parent
a7522c7734
commit
49d6bd3b67
2 changed files with 10 additions and 4 deletions
|
@ -1,6 +1,12 @@
|
||||||
|
var NEW_PROJECT_HASH = 'createEmptyProject';
|
||||||
|
|
||||||
var loadProject = function () {
|
var loadProject = function () {
|
||||||
var id = location.hash.substring(1);
|
var id = location.hash.substring(1);
|
||||||
if (id.length < 1) {
|
if (id === NEW_PROJECT_HASH) {
|
||||||
|
window.vm.createEmptyProject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (id.length < 1 || !isFinite(id)) {
|
||||||
id = '119615668';
|
id = '119615668';
|
||||||
}
|
}
|
||||||
var url = 'https://projects.scratch.mit.edu/internalapi/project/' +
|
var url = 'https://projects.scratch.mit.edu/internalapi/project/' +
|
||||||
|
@ -32,7 +38,7 @@ window.onload = function() {
|
||||||
};
|
};
|
||||||
document.getElementById('createEmptyProject').addEventListener('click',
|
document.getElementById('createEmptyProject').addEventListener('click',
|
||||||
function() {
|
function() {
|
||||||
document.location = '#' + 'createEmptyProject';
|
document.location = '#' + NEW_PROJECT_HASH;
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
loadProject();
|
loadProject();
|
||||||
|
|
|
@ -132,7 +132,7 @@ VirtualMachine.prototype.loadProject = function (json) {
|
||||||
VirtualMachine.prototype.createEmptyProject = function () {
|
VirtualMachine.prototype.createEmptyProject = function () {
|
||||||
// Stage.
|
// Stage.
|
||||||
var blocks2 = new Blocks();
|
var blocks2 = new Blocks();
|
||||||
var stage = new Sprite(blocks2);
|
var stage = new Sprite(blocks2, this.runtime);
|
||||||
stage.name = 'Stage';
|
stage.name = 'Stage';
|
||||||
stage.costumes.push({
|
stage.costumes.push({
|
||||||
skin: '/assets/stage.png',
|
skin: '/assets/stage.png',
|
||||||
|
@ -151,7 +151,7 @@ VirtualMachine.prototype.createEmptyProject = function () {
|
||||||
target2.isStage = true;
|
target2.isStage = true;
|
||||||
// Sprite1 (cat).
|
// Sprite1 (cat).
|
||||||
var blocks1 = new Blocks();
|
var blocks1 = new Blocks();
|
||||||
var sprite = new Sprite(blocks1);
|
var sprite = new Sprite(blocks1, this.runtime);
|
||||||
sprite.name = 'Sprite1';
|
sprite.name = 'Sprite1';
|
||||||
sprite.costumes.push({
|
sprite.costumes.push({
|
||||||
skin: '/assets/scratch_cat.svg',
|
skin: '/assets/scratch_cat.svg',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue