Ejemplo n.º 1
0
  @Override
  public Sprite clone() {
    final Sprite cloneSprite = new Sprite();

    cloneSprite.setName(this.getName());
    cloneSprite.isBackpackObject = false;

    Project currentProject = ProjectManager.getInstance().getCurrentProject();
    if (currentProject == null || !currentProject.getSpriteList().contains(this)) {
      throw new RuntimeException("The sprite must be in the current project before cloning it.");
    }

    Sprite originalSprite = ProjectManager.getInstance().getCurrentSprite();
    ProjectManager.getInstance().setCurrentSprite(cloneSprite);

    cloneSpriteVariables(currentProject, cloneSprite);
    cloneLooks(cloneSprite);
    cloneSounds(cloneSprite);
    cloneUserBricks(cloneSprite);
    cloneNfcTags(cloneSprite);
    cloneScripts(cloneSprite);

    setUserAndVariableBrickReferences(cloneSprite, userBricks);

    ProjectManager.getInstance().checkCurrentSprite(cloneSprite, false);
    ProjectManager.getInstance().setCurrentSprite(originalSprite);

    return cloneSprite;
  }
Ejemplo n.º 2
0
 public void rename(String newSpriteName) {
   if ((getRequiredResources() & Brick.PHYSICS) > 0) {
     List<Sprite> spriteList = ProjectManager.getInstance().getCurrentProject().getSpriteList();
     for (Sprite currentSprite : spriteList) {
       if ((currentSprite.getRequiredResources() & Brick.PHYSICS) > 0) {
         currentSprite.updateCollisionBroadcastMessages(getName(), newSpriteName);
       }
     }
   }
   setName(newSpriteName);
 }
Ejemplo n.º 3
0
 public Sprite cloneForBackPack() {
   final Sprite cloneSprite = new Sprite();
   cloneSprite.setName(this.getName());
   return cloneSprite;
 }