Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Code] Aligning World Plane to Display Plane - Easiest Yet

Author
Message
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 25th Jun 2014 01:40 Edited at: 25th Jun 2014 01:44
A very easy function which will align a pixel on the world plane with a pixel on the display plane at a given zoom level.

Intended to enhance setviewoffset()

For example, if you have a sprite on the world plane and you'd like to center the display on it, use;
AlignWorld( getSpriteXByOffset( sprite ) ,getSpriteYByOffset( sprite ) , getVirtualWidth() * 0.5 , getVirtualHeight() * 0.5 , 1.0 ).

For a better example, here a little app which moves four sprites around the screen. At the bottom of the screen are 4 smaller windows - each of which will stay locked on one of the sprites at varying zoom levels


Edit:

Also if you touch the screen, the first box will follow the pointer - while its contents will stay centered on it's sprite

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-25 06:38:09
Your offset time is: 2024-11-25 06:38:09