I need help for this code I need, its a Zoom in and Zoom out buttons but I dont know how to make the code for it
here is the wick that you can use if you want to tweak the buttons
I need help for this code I need, its a Zoom in and Zoom out buttons but I dont know how to make the code for it
here is the wick that you can use if you want to tweak the buttons
oh i cant post it because Iam new but here is a Image
I, personally, don’t really know that much Javascript but you can probably make something zoom-in without directly zooming it in. Now I’m gonna need some more context on what you’re trying to make so I can directly tell you what to do while helping you but what I can do now is give you an example!
So if you want to create a map then instead of zooming in, you could just make the map bigger and create the illusion of zooming in. You could create an example map and name it “examp_map” or whatevs you want. Then you could make two buttons, a zoom in and zoom out. For the zoom in button, you could add a Mousclick script and inside write
examp_map.width = examp_map.width*2;
examp_map.height = examp_map.height*2;
I’m gonna break down the first line. examp_map is the name of the map object, .width means the width of the map object. “=” sets the variable that contains the width of the map object to the following value which is the width of the map object multiplied by two. The second line does the exact same thing except for the height of the object. When pressed now, the example map should be twice the size! To make a zoom out, you could just copy the button and in the code replace “*” with “/” which divides it.
Wait, I’m dumb. You can just add the built-in Vcam in the asset library and name it “vcam” or some crap and replace all the code in the buttons that mention “examp_map” with “vcam”.
@schulztrey welcome to the forums! Also, you’re not dumb, you’ve just listed two different solutions, and each one has their own advantages and disadvantages.
The only downside here with using the vcam is the fact that you’d be zooming in on your entire project. In other words, your buttons will also be affected by this since they’d appear bigger in size, which in some cases might mean more trouble if you want to keep everything smaller and easier to click.
An easy solution would be to just have all of your buttons inside of the vcam itself, or you could go with @schulztrey first solution of changing the size of the object you want to “zoom” in or out of.
If you need the code for something like configuring the users screen size, then that might not be much of a problem with the vcam method. You can use window.innerWidth
and window.innerHeight
as well to get the width and height of the window, and use that as the default size of the vcam (there might be some math there)
thank you .