Skip to content
Snippets Groups Projects
Commit 0bbf92f9 authored by Karishma Chadha's avatar Karishma Chadha
Browse files

Update calls to addSprite2 to use new API for adding sprites. Cleanup sprite3...

Update calls to addSprite2 to use new API for adding sprites. Cleanup sprite3 representation for uploading a new sprite from an image.
parent 82000885
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class SpriteLibrary extends React.PureComponent {
clearInterval(this.intervalId);
}
handleItemSelect (item) {
this.props.vm.addSprite2(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json));
analytics.event({
category: 'library',
action: 'Select Sprite',
......
......@@ -72,13 +72,13 @@ class TargetPane extends React.Component {
}
handleSurpriseSpriteClick () {
const item = spriteLibraryContent[Math.floor(Math.random() * spriteLibraryContent.length)];
this.props.vm.addSprite2(JSON.stringify(item.json));
this.props.vm.addSprite(JSON.stringify(item.json));
}
handlePaintSpriteClick () {
// @todo this is brittle, will need to be refactored for localized libraries
const emptyItem = spriteLibraryContent.find(item => item.name === 'Empty');
if (emptyItem) {
this.props.vm.addSprite2(JSON.stringify(emptyItem.json)).then(() => {
this.props.vm.addSprite(JSON.stringify(emptyItem.json)).then(() => {
setTimeout(() => { // Wait for targets update to propagate before tab switching
this.props.onActivateTab(COSTUMES_TAB_INDEX);
});
......@@ -86,7 +86,7 @@ class TargetPane extends React.Component {
}
}
handleNewSprite (spriteJSONString) {
this.props.vm.addSprite(spriteJSONString); // TODO change all instances of addSprite2 to addSprite?
this.props.vm.addSprite(spriteJSONString);
}
handleFileUploadClick () {
this.fileInput.click();
......
......@@ -189,24 +189,20 @@ const spriteUpload = function (fileData, fileType, spriteName, storage, handleSp
// let costume = null;
costumeUpload(fileData, fileType, `${spriteName}-costume1`, storage, (vmCostume => {
const newSprite = {
targets: [{
name: spriteName,
isStage: false,
x: 0, // what should we put here...
y: 0,
visible: true,
size: 100,
rotationStyle: 'all around',
direction: 90,
draggable: true,
currentCostume: 0,
blocks: {},
variables: {},
lists: {},
broadcasts: {},
costumes: [vmCostume],
sounds: [] // TODO are all of these necessary?
}]
name: spriteName,
isStage: false,
x: 0,
y: 0,
visible: true,
size: 100,
rotationStyle: 'all around',
direction: 90,
draggable: true,
currentCostume: 0,
blocks: {},
variables: {},
costumes: [vmCostume],
sounds: [] // TODO are all of these necessary?
};
// TODO probably just want sprite upload to handle this object directly
handleSprite(JSON.stringify(newSprite));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment