Start a new topic
Solved

How change image resource in image drawable?

Hello, i try to switch between two image resources in one image drawable, but can't.
This is my code:

 

var imgOne = new AR.ImageResource("assets/models/point.png", {

onError: World.onError

});


var imgTwo = new AR.ImageResource("assets/models/selected-point.png", {

onError: World.onError

});


this.arTrackable = new AR.ImageTrackable(this.tracker, "*", {

onImageRecognized: function (target) {

var model = new AR.ImageDrawable(imgOne, 1, {

translate: { x: -0.15 },

onClick: function () {

 // HERE I wanna change imgOne with imgTwo and on next click switch again

}

});


this.addImageTargetCamDrawables(target, model);

World.hideInfoBar();

},

onError: World.onError

});

},

Thanks!


Hi Gyuner,


Could you please also provide further details on what happens if you switch images? 


You can e.g. check the implementation in the SDK sample app 'Selecting POIs'. This sample includes the behavior that if a POI marker is clicked the image is changed. 


Please have a look at this sample and the respective documentation.


Thx and greetings

Nicola


1 person likes this

Thanks, I was able to do it with a similar approach.

Login or Signup to post a comment