FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

translating SIO2widget

3 posters

Go down

translating SIO2widget Empty translating SIO2widget

Post  meteors Wed Mar 25, 2009 10:09 am

Hi all,

I'm a bit confused as to why SIO2widget has a member SIO2transform. Shouldn't widget locations be in 2D int coordinates?

What's the proper way to move an SIO2widget around on the screen?


Thanks!! Best,
-j
meteors
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  sw Wed Mar 25, 2009 10:12 am

maybe you need to move your collimator when you move your gun. Smile
sw
sw

Posts : 73
Join date : 2008-10-12

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  meteors Wed Mar 25, 2009 10:44 am

Har har.

And it's a crosshair, thank you very much :-)


-j
meteors
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  uprise78 Wed Mar 25, 2009 10:53 am

You can move a widget around pretty easily like this:

myWidget->_SIO2transform->loc->x += d.y;
myWidget->_SIO2transform->loc->y -= d.x;

I am actually in the process of making sio2Sprite for a 2d game. sio2Widget doesn't have quite enough functionality for 2d games. Up until today, I was using an sio2Widget as the backing store for the sprite, but I am branching it now to be it's own type. It will allow easy movement, scaling, fading, animations, etc. Once it's done, I will send it over to SIO2 and if he wants it to be part of the SDK it will be his to include.

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  meteors Wed Mar 25, 2009 11:07 am

Thanks, but where are you getting d, x, and y :-)


-j
meteors
meteors

Posts : 241
Join date : 2008-11-08
Location : Sunny Florida

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  uprise78 Wed Mar 25, 2009 11:29 am

I should have explained that...

d is just a vec2. d.x and d.y are just the distance a finger moved on the screen. The following code snippet should let you know where they came from. It has some extra stuff that you can disregard from the sprite class i mentioned...

Code:
vec2 start;
void templateScreenTap( void *_ptr, unsigned char _state )
{
   if( _state == SIO2_WINDOW_TAP_DOWN )
   {
      // Set a flag to show we are being touched
      beingTouched = 1;
      
      // Start the animation timer
      sio2TimerPlay( myTimer );
      
      // Save our start x position so we can figure out where to move if TouchMoved gets called
      start.x = sio2->_SIO2window->touch[ 0 ].x;
      start.y = sio2->_SIO2window->touch[ 0 ].y;
   }
   else
   {
      // Reset the flag so our widget zooms back out
      beingTouched = 0;
      
      // Stop the timer
      sio2TimerStop( myTimer );
   }
}


void templateScreenTouchMove( void *_ptr )
{
   vec2 d;
   d.y = sio2->_SIO2window->touch[ 0 ].x - start.x;
   d.x = start.y - sio2->_SIO2window->touch[ 0 ].y;
   
   myWidget->_SIO2transform->loc->x += d.y;
   myWidget->_SIO2transform->loc->y -= d.x;
   
   start = sio2->_SIO2window->touch[ 0 ];
}

uprise78

Posts : 228
Join date : 2008-10-31

Back to top Go down

translating SIO2widget Empty Re: translating SIO2widget

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum