translating SIO2widget
3 posters
translating SIO2widget
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
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- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: translating SIO2widget
maybe you need to move your collimator when you move your gun.
sw- Posts : 73
Join date : 2008-10-12
Re: translating SIO2widget
Har har.
And it's a crosshair, thank you very much :-)
-j
And it's a crosshair, thank you very much :-)
-j
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: translating SIO2widget
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.
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
Re: translating SIO2widget
Thanks, but where are you getting d, x, and y :-)
-j
-j
meteors- Posts : 241
Join date : 2008-11-08
Location : Sunny Florida
Re: translating SIO2widget
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...
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
Similar topics
» SIO2Widget help
» SIO2widget in v1.3??
» SIO2widget change in 1.4?
» How to use a sio2widget as a textbox?
» Rotating SIO2Widget?
» SIO2widget in v1.3??
» SIO2widget change in 1.4?
» How to use a sio2widget as a textbox?
» Rotating SIO2Widget?
Permissions in this forum:
You cannot reply to topics in this forum