Hello,
I'm trying to make a scrolling map window which mostly is working great.
I've tried to add zoom functions but can't work out how to do the maths that calculates how the x and y should change with the scale of the image? Anyone any ideas?
Here's my code so far, it's bodged from the scrolling textbox. I assume it's the speed element that's not working. I'm trying a bit of trial and error on the values.
The next stage is going to be limiting the image so it doesn't get smaller than the mask or is not scrolled too far either direction so the edge shows. I assume this is going to be through an 'if' statement but if anyone has any ideas it would be much appriciated!
Code
<plugin name="map" url="textfield.png" align="lefttop" x="10" y="10" zorder="60" scale9grid="5|5|12|55" width="280" height="40%" keep="true" onhover=""/>
<plugin name="map_mask" url="box.png" parent="map" align="lefttop" x="5" width="95%" y="5" height="95%" keep="true"/>
<plugin name="map_image" url="map.jpg" keep="true" enabled="true" parent="map" scale="1" zorder="69" align="lefttop" x="-542" y="-238" background="false" borderwidth="0" mask="map_mask"/>
<plugin name="map_scrollup" url="dirbutton.png" keep="true" parent="map" zorder="71" align="righttop" x="24" y="5" rotate="-90" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="tween(plugin[map_image].y, 10, distance(400,0.7), linear);" onup="stoptween(plugin[map_image].y);"/>
<plugin name="map_scrolldown" url="dirbutton.png" keep="true" parent="map" zorder="72" align="rightbottom" x="24" y="5" rotate="+90" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="tween(plugin[map_image].y, -690, distance(400,0.7), linear);" onup="stoptween(plugin[map_image].y);"/>
<plugin name="map_scrollleft" url="dirbutton.png" keep="true" parent="map" zorder="73" align="leftbottom" x="24" y="24" rotate="+180" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="tween(plugin[map_image].x, 10, distance(400,0.7), linear);" onup="stoptween(plugin[map_image].x);"/>
<plugin name="map_scrollright" url="dirbutton.png" keep="true" parent="map" zorder="74" align="rightbottom" x="24" y="5" rotate="0" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="tween(plugin[map_image].x, -1000, distance(400,0.7), linear);" onup="stoptween(plugin[map_image].x);"/>
<plugin name="map_zoomin" url="zinbutton.png" keep="true" parent="map" zorder="75" align="rightbottom" x="44" y="5" rotate="0" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="action(map_zoom_in)" onup="action(stop_map_zoom)"/>
<plugin name="map_zoomout" url="zoutbutton.png" keep="true" parent="map" zorder="76" align="rightbottom" x="64" y="5" rotate="0" crop="0|0|19|19" onovercrop="0|19|19|19" ondowncrop="0|38|19|19" ondown="action(map_zoom_out)" onup="action(stop_map_zoom)"/>
<action name="map_zoom_in">
tween(plugin[map_image].scale, 2, distance(1.6,0.7), linear);
tween(plugin[map_image].y, -690, distance(700,0.7), linear);
tween(plugin[map_image].x, -1000, distance(1000,0.7), linear);
</action>
<action name="map_zoom_out">
tween(plugin[map_image].scale, 0.4, distance(1.6,0.7), linear);
tween(plugin[map_image].y, 10, distance(200,0.7), linear);
tween(plugin[map_image].x, 10, distance(200,0.7), linear);
</action>
<action name="stop_map_zoom">
stoptween(plugin[map_image].scale);
stoptween(plugin[map_image].y);
stoptween(plugin[map_image].x);
</action>
Alles anzeigen