scale specific coordinates?

For developers using the Construct 2 Javascript SDK

Post » Sun Jul 06, 2014 12:58 pm

Hi there, could someone please point me in the right direction for figuring out the x and y coordinates taking into account scale? The code I have works perfectly until I change the fullscreen mode from crop to anything else. I would like to scale the code much like the button does but I don't see details on how many of the items such as layerToCanvas actually work.

Heres my code

Acts.prototype.Like_Button = function (l_verb, l_color, l_under, l_layout,l_faces,l_url,l_code)
{
var left = fbInst.x;
var top = fbInst.y;
var verb1, color1, under1, layout1, faces1, url1, code1;
if (l_under == 0){under1 = true;}else{under1= false;}
if (l_faces == 0){faces1 = true;}else{faces1= false;}
if (l_verb == 0){verb1 = 'like';}else{verb1= 'recommend';}
if (l_color == 0){color1 = 'light';}else{color1= 'dark';}
if (l_layout == 0){layout1 = 'standard';}
else if (l_layout == 1){layout1 = 'button_count';}
else if (l_layout == 2){layout1 = 'button';}
else{layout1= 'box_count';}
var div1 = document.createElement("div");
div1.style.position="absolute";
div1.style.left=left+"px";
div1.style.top = top+"px";
div1.style.width = fbInst.width+"px";
div1.style.height = fbInst.height+"px";
div1.style.zIndex="10000000";
div1.innerHTML = '<div class="fb-like" kid_directed_site="'+under1+'" colorscheme= "'+color1+'"data-href="'+l_url+'" data-layout="'+layout1+'" data-action="'+verb1+'" data-show-faces="'+faces1+'" data-share="true" data-ref="'+l_code+'"></div>';
document.body.appendChild (div1);
FB.XFBML.parse();

};
www.h1k3.tech

We are here for you!
B
87
S
22
G
16
Posts: 715
Reputation: 16,785

Post » Sun Jul 06, 2014 1:09 pm

Just look at the source to one of the other plugins like Text Box or Progress Bar. They show how to correctly position a DOM element over the canvas.
Scirra Founder
B
398
S
236
G
88
Posts: 24,433
Reputation: 194,635


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 2 guests