mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-06-05 10:03:56 -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 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';
|
||||
}
|
||||
var url = 'https://projects.scratch.mit.edu/internalapi/project/' +
|
||||
|
@ -32,7 +38,7 @@ window.onload = function() {
|
|||
};
|
||||
document.getElementById('createEmptyProject').addEventListener('click',
|
||||
function() {
|
||||
document.location = '#' + 'createEmptyProject';
|
||||
document.location = '#' + NEW_PROJECT_HASH;
|
||||
location.reload();
|
||||
});
|
||||
loadProject();
|
||||
|
|
|
@ -132,7 +132,7 @@ VirtualMachine.prototype.loadProject = function (json) {
|
|||
VirtualMachine.prototype.createEmptyProject = function () {
|
||||
// Stage.
|
||||
var blocks2 = new Blocks();
|
||||
var stage = new Sprite(blocks2);
|
||||
var stage = new Sprite(blocks2, this.runtime);
|
||||
stage.name = 'Stage';
|
||||
stage.costumes.push({
|
||||
skin: '/assets/stage.png',
|
||||
|
@ -151,7 +151,7 @@ VirtualMachine.prototype.createEmptyProject = function () {
|
|||
target2.isStage = true;
|
||||
// Sprite1 (cat).
|
||||
var blocks1 = new Blocks();
|
||||
var sprite = new Sprite(blocks1);
|
||||
var sprite = new Sprite(blocks1, this.runtime);
|
||||
sprite.name = 'Sprite1';
|
||||
sprite.costumes.push({
|
||||
skin: '/assets/scratch_cat.svg',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue