Detecting of pressing button on sprite September 28, 2014 02:28PM | Registered: 14 years ago Posts: 55 |
Re: Detecting of pressing button on sprite September 29, 2014 11:52AM | Registered: 14 years ago Posts: 55 |
if (ML_IsWiimoteInSprite(0, &reset) && (Wiimote[0].Newpress.A))It goes like this:
Re: Detecting of pressing button on sprite October 01, 2014 01:48AM | Registered: 13 years ago Posts: 363 |
Re: Detecting of pressing button on sprite October 01, 2014 10:51PM | Registered: 14 years ago Posts: 55 |
The button detections seems to be working just fine (Home button FTW), however for now I wasn't able to make cursor appear on the screen and follow the x,y positioning, I will try the more basic example of drawing white square instead of using the image for nowQuote
I am assuming know how to detect the button press events and how to know where the pointer is on the screen.
Re: Detecting of pressing button on sprite October 02, 2014 01:52AM | Registered: 13 years ago Posts: 363 |
#define SPRITESHEET_MAX 30 #define GROUP_MAX 10 //============================================================================ typedef struct { GRRLIB_texImg *sprite; bool is_loaded; float x, y; } SpriteSheetStruct; SpriteSheetStruct ssl[SPRITESHEET_MAX]; //spritesheet_list GRRLIB_texImg * spritesheet_get_pointer( int ind ){ if(ind > SPRITESHEET_MAX-1) return NULL; if(!ssl[ind].is_loaded) return NULL; return ssl[ind].sprite; } void spritesheet_load( int ind, const char *fileName, int width, int height, int start, int stop ){ //load a sprite sheet if(ind > SPRITESHEET_MAX-1) return; engine_print( "Loading SpriteFile; " ); engine_print(fileName ); ssl[ind].sprite=GRRLIB_LoadTextureFromFile(fileName); if( ssl[ind].sprite!=NULL ) GRRLIB_InitTileSet( ssl[ind].sprite, width, height, start ); ssl[ind].is_loaded=( ssl[ind].sprite!=NULL ); if( !ssl[ind].is_loaded ) { engine_println( "...error!" ); return; } //error engine_println( "...done." ); } void spritesheet_free(int ind){ //free memory if(ind > SPRITESHEET_MAX-1) return; if( ssl[ind].is_loaded ) GRRLIB_FreeTexture(ssl[ind].sprite); } void spritesheet_free_all(){ //free memory int i; for( i=0;ithen I use the functions like so; spritesheet_load( S_DIALOGBOX, "image/dialogbox.png", 640, 480, 0, 1 ); spritesheet_midhandle( S_DIALOGBOX, TRUE );GRRLIB_DrawImg( screen_center_x, screen_center_y, spritesheet_get_pointer(S_DIALOGBOX), 0, 1, 1, background_col[enemy_col_index] );so when you are doing the check for the button press you just use a loop;int i; for( i=0;i<SPRITESHEET_MAX;i++) { if( ssl.x > pointer_x & ssl.y > pointer_y & & & & blah blah ) { //do something } }
Edited 1 time(s). Last edit at 10/02/2014 02:05AM by owen.