Script Error
ambiggs

I am following the instructions of the Spot the Difference tutotiral to make a seek and find game. However, I'm getting a script error:

Script error in band aid .onAddToScene: Unexpected token +

The code I'm using is:

var clone + this.clone();
clone.setPosition(this.getPostion().x + 298, this.getPostion().y  +180.2682889553746);
wade.addSceneObject(clone, true);

 

Again, what I'm TRYING to do is link a sprite to another so when the orginal sprite is clicked, the second sprite will be added to the scene in another spot. 

Ideally, I'd be using two different images for the sprites, but since I can't figure that out, I figured I'd try the cloning feature. 

 

Can someone help?

All 2 Comments
ambiggs

Also getting this error: Uncaught TypeError: Cannot read property 'getSprite' of undefined (app.html, 4:19)

On add to scene

var clone + this.clone();
clone.setPosition(this.getPostion().x + 298, this.getPostion().y  +180.2682889553746);
clone.onAddToScene = null;
wade.addSceneObject(clone, true);

this.clonedObject = clone;
clone.clonedObject = this;

 

on mouse down:

this.getSprite(0).setVisible(true);
this.cloneObject.getSprite(0).setVisible(true);

Gio

Hi

It's a syntax error in 

var clone + this.clone();

You should replace the + with an =

Saying that, I have replied in another thread suggesting a different way to achieve what you want, which may be easier.

Post a reply
Add Attachment
Submit Reply
Login to Reply