SIO2Widget area - getting some strange results..
2 posters
SIO2Widget area - getting some strange results..
Hi,
I'm using SIO2widgets to render my 2d main menu, including the background and three buttons (all seperate widgets). Each of the button widgets has a tapdown event, and I have set the area to be the image->width and image->height of the button, but I'm noticing that the tapdown detection is triggering in odd places, and not where i'd expect (i.e., over the image).
I've modified one of the tutorials in the past and the tapdown area worked as expected, but in this case even when I've used exactly the same code I'm getting different results for each button... I.e, one area seems to be rotated around the origin, one area seems to rotated and moved, etc... so I figure its some to do with the transforms, but nothing I've tried so far makes any sense, so assume I'm missing some state reset that didnt affect things when only one widget/button was used in my earlier testing.
A few snippets of the code im using...
Init:
And render:
Any one have any ideas where I'm going wrong here or where I should look at?
Many thanks...
I'm using SIO2widgets to render my 2d main menu, including the background and three buttons (all seperate widgets). Each of the button widgets has a tapdown event, and I have set the area to be the image->width and image->height of the button, but I'm noticing that the tapdown detection is triggering in odd places, and not where i'd expect (i.e., over the image).
I've modified one of the tutorials in the past and the tapdown area worked as expected, but in this case even when I've used exactly the same code I'm getting different results for each button... I.e, one area seems to be rotated around the origin, one area seems to rotated and moved, etc... so I figure its some to do with the transforms, but nothing I've tried so far makes any sense, so assume I'm missing some state reset that didnt affect things when only one widget/button was used in my earlier testing.
A few snippets of the code im using...
Init:
- Code:
// Load button1
{
// Intialise the widget
_FTLMainMenu->mainMenu_Button1 = sio2WidgetInit( "mainMenu_Button1" );
_SIO2material = sio2MaterialInit( "mainMenu_Button1" );
_SIO2image = sio2ImageInit ( "mainMenu_Button1" );
_SIO2stream = sio2StreamInit("");
_SIO2stream = sio2StreamOpen( "mainMenu-Button1-1.jpg", 1 );
{
sio2ImageLoad( _SIO2image, _SIO2stream );
sio2ImageGenId( _SIO2image, 0, 0.0f );
}
_SIO2stream = sio2StreamClose( _SIO2stream );
/* omitted for clarity */
// Resize the widget to be the width and the height of the image.
_FTLMainMenu->mainMenu_Button1->_SIO2transform->scl->x = _SIO2image->width;
_FTLMainMenu->mainMenu_Button1->_SIO2transform->scl->y = _SIO2image->height;
// Widget location
_FTLMainMenu->mainMenu_Button1->_SIO2transform->loc->x = 240.0f;
_FTLMainMenu->mainMenu_Button1->_SIO2transform->loc->y = 260.0f;
// Widget area
_FTLMainMenu->mainMenu_Button1->area->x = _SIO2image->width;
_FTLMainMenu->mainMenu_Button1->area->y = _SIO2image->height;
// Assign action methods
_FTLMainMenu->mainMenu_Button1->_SIO2widgettapdown = button1_down;
// Assign the transformation matrix
sio2TransformBindMatrix( _FTLMainMenu->mainMenu_Button1->_SIO2transform );
sio2EnableState( &_FTLMainMenu->mainMenu_Button1->flags, SIO2_WIDGET_ENABLED | SIO2_WIDGET_CENTERED);
}
sio2ResourceUpdateAllWidgetBoundaries( _FTLMainMenu->mainMenu_Resource,
sio2->_SIO2window );
And render:
- Code:
sio2WindowEnter2D( sio2->_SIO2window, 0.0f, 100.0f );
{
sio2WindowEnterLandscape2D( sio2->_SIO2window );
{
//Render button1
sio2WidgetRender( sio2ResourceGetWidget( ftlgame->_FTLMainMenu->mainMenu_Resource, "mainMenu_Button1" ),
sio2->_SIO2window,
SIO2_TRANSFORM_MATRIX_BIND );
sio2WidgetReset();
sio2MaterialReset();
/* omitted for clarity */
Any one have any ideas where I'm going wrong here or where I should look at?
Many thanks...
Krypt- Posts : 15
Join date : 2009-09-21
Re: SIO2Widget area - getting some strange results..
Take a look at the meditation garden source code, you got it all covered there...
Re: SIO2Widget area - getting some strange results..
Hi ROm,
I'm using the meditation garden source code as guidance (along with my own re-creations of the tutorials), and I've got to the point now where I've stripped all other code out other than 1 widget and still am having problems correctly calculating the area and applying the transform.
The widget displays correctly, and using the same scale calculations, I calculate the area.... the area works, but its rotated 90 degrees (like its displaying in portrait mode) and is slightly off centre. I can change the area x/y values (swap them) and its sort of in the right position, but is still not correctly centered. I've confirmed that the window is in landscape mode, so I don't understand how the area is not matching the widget. I've gone through the meditation garden code a couple of times now and cant see anything different that you've done to calculate the area (i used the same method), so am at a loss to understand why the area doesn't match the widget.
What else could it be?
I'm using the meditation garden source code as guidance (along with my own re-creations of the tutorials), and I've got to the point now where I've stripped all other code out other than 1 widget and still am having problems correctly calculating the area and applying the transform.
The widget displays correctly, and using the same scale calculations, I calculate the area.... the area works, but its rotated 90 degrees (like its displaying in portrait mode) and is slightly off centre. I can change the area x/y values (swap them) and its sort of in the right position, but is still not correctly centered. I've confirmed that the window is in landscape mode, so I don't understand how the area is not matching the widget. I've gone through the meditation garden code a couple of times now and cant see anything different that you've done to calculate the area (i used the same method), so am at a loss to understand why the area doesn't match the widget.
What else could it be?
Krypt- Posts : 15
Join date : 2009-09-21
Re: SIO2Widget area - getting some strange results..
Im not sure I fully understand maybe post some screenshots
Similar topics
» how to correct sio2widget area using portrait ??
» strange problem
» Strange problem with sio2ObjectMapBuffer
» strange alpha behaviour
» SIO2Widget help
» strange problem
» Strange problem with sio2ObjectMapBuffer
» strange alpha behaviour
» SIO2Widget help
Permissions in this forum:
You cannot reply to topics in this forum
|
|