Skip to main content
Inspiring
February 26, 2021
Question

HTML5 canvas camera - control with code

  • February 26, 2021
  • 1 reply
  • 545 views

I'm using the adobe help guide for the camera methods etc... 

https://helpx.adobe.com/animate/user-guide.html/animate/using/working-with-camera-in-animate.ug.html

I'm trying to control the camera via code.

I now want to zoom in on certain words on the stage ie: to give emphasis and make things more dynamic.

I enclose the end snippet of code I am using. It doesn't zoom in.

 

function addPopup() {
	
	//this.s1_b4.visible=false; -- WARNING - don't put stuff before declaring variables.
	
	var Tania = new lib.popup_Tania();
    Tania.x = 350;
    Tania.y = 450;
	exportRoot.addChild(Tania);
	
	cameraZoom();
}

function cameraZoom() {
	
		var cameraObj = AdobeAn.VirtualCamera.getCamera(exportRoot);
	
		this.cameraObj.setPosition(100,100,100);
	    this.cameraObj.setZoom(200);
		//this.cameraObj.zoomBy(100);
}

 

    This topic has been closed for replies.

    1 reply

    Inspiring
    February 26, 2021

     

    I have also found this code ie: I want to zoom in on the w2 object. Then zoom out after 5 seconds.

     

    var cameraObj = AdobeAn.VirtualCamera.getCamera(exportRoot).pinCameraToObject(_this.w2, 0, 0);

    Inspiring
    February 26, 2021

    OK - I'm getting really close.

     

    var zoomPercent = 200;
    var cameraObj = AdobeAn.VirtualCamera.getCamera(exportRoot).zoomBy(zoomPercent);

     

    This zooms in, however with no control, I want to zoom in on a specific text object called w2 and I'm not sure how to do that. It's also doesn't zoom in with a tween, but straight in.