Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
zooming with keyboard button

isamarty
Guest
Quote
2021-05-21 19:14:44

please help me

i want to zoom camera when click on a 2d overley


i have tested the extension(script) but it wont work on android

please soomeone make me a script which zoom camera with keyboard buttons i will then port it on 2d touch overlay please please


Sven
Guest
Quote
2021-05-22 18:22:18

This should give you idea. (read comments that i added in script-file)

/*
<behavior jsname="behavior_Keyboard_M" description="KEYBOARD EXAMPLE">

</behavior>
*/

var keyp=0;//on android change it.. if overlay1 (zoom in) clicked then keyp=77 if overlay2 (zoom out) clicked then keyp=78
var counter=0;

ccbRegisterKeyDownEvent("keyPressedDown");//on android remove it
function keyPressedDown(keyCode)//on android remove it
{//on android remove it
keyp=keyCode;//on android remove it
}//on android remove it


behavior_Keyboard_M = function()
{
};

behavior_Keyboard_M.prototype.onAnimate = function()
{




//IS M PRESSED DOWN
if (keyp==77 )//on android change it.. if overlay1 (zoom in) clicked then keyp=77 if overlay2 (zoom out) clicked then keyp=78
{
keyp=0;//RESET
counter+=0.1;
var cam = ccbGetActiveCamera();
var Fov = ccbGetSceneNodeProperty(cam, 'FieldOfView_Degrees');
ccbSetSceneNodeProperty(cam, 'FieldOfView_Degrees', Fov-counter);
}

//IS N PRESSED DOWN
if (keyp==78 )//on android change it.. if overlay1 (zoom in) clicked then keyp=77 if overlay2 (zoom out) clicked then keyp=78
{
keyp=0;//RESET
counter+=0.1;
var cam = ccbGetActiveCamera();
var Fov = ccbGetSceneNodeProperty(cam, 'FieldOfView_Degrees');
ccbSetSceneNodeProperty(cam, 'FieldOfView_Degrees', Fov+counter);
}


return true;
}




Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Inte?national" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact