W
Wraithious
Guest
Hello, I have a project that creates pages for a book and shows them, it works perfectly fine on windows.
This is the problem:
On android the scale is wayyyy off on the images for the pages in the book, but somehow the size of the page's sprites are correct. Here's pics to illustrate what should happen and what is happening:
I made a small gmz project that demonstrates the issue, actually I'll post the troublesome code in a spoiler too, anyways if anyone could please download it and first try it on windows and see it is working perfect, then try on android and you'll immediately see what is happening, the only 2 places I can see there might be an error is in the script droidSave, or the second action in the controller step event titled MAKE PAGES. (there is only 1 object and 1 script in the example project)
to use the example
press/left click new page and when the button pops back up the page is ready to view, there are 5 backgrounds you can save.
press/left click view page to show or hide the book.
press/left click up or down to turn the pages.
press backspace (android) or escape (windows) to quit
Here is the GMZ.
So when I comment out some stuff in the droidSave script and change it to save the surface and use alarm 1 exactly how the windows version does it still has the same exact error:
The only hint I have as to what's happening is that each time you save a page, the resulting image displayed on every page gets more and more magnified every time, what could be causing this??
This is the problem:
On android the scale is wayyyy off on the images for the pages in the book, but somehow the size of the page's sprites are correct. Here's pics to illustrate what should happen and what is happening:
to use the example
press/left click new page and when the button pops back up the page is ready to view, there are 5 backgrounds you can save.
press/left click view page to show or hide the book.
press/left click up or down to turn the pages.
press backspace (android) or escape (windows) to quit
Here is the GMZ.
droidSave script:
MAKE PAGE code, in step event:
alarm2 code:
Code:
var wth=surface_get_width(application_surface);
var hgt=surface_get_height(application_surface);
surf = application_surface;
surface_set_target(surf);
spr3 = sprite_create_from_surface(surf,0,0,wth,hgt,false,false,0,0);
surface_free(surf);
surface_reset_target();
sprite_assign(spr_temp,spr3);
sprite_assign(spr_temp2,spr3);
sprite_delete(spr3);
e=400/sprite_get_width(spr_temp);
f=225/sprite_get_height(spr_temp);
global.snapshot=1; //this activates the step event MAKE PAGES
Code:
///MAKE PAGES
if(global.snapshot=1)
{global.maxpage+=1;
sur=surface_create(400*(global.maxpage+1),225);surface_set_target(sur);draw_clear_alpha(-1,0);//spr_content
for(var i=0;i<global.maxpage+1;i+=1;){if i<global.maxpage draw_sprite(spr_content,i,400*i,0);
if(i=global.maxpage){draw_sprite_ext(spr_temp,0,400*i,0,e,f,0,-1,1);
draw_set_color(c_blue);draw_text(((200+(400*i))-13),209,"("+string((i+1))+")");}
}
surface_reset_target();
spr=sprite_create_from_surface(sur,0,0,400*(global.maxpage+1),225,0,0,0,0);
sprite_save_strip(spr, "spr_content.png");surface_free(sur);
sur=surface_create(400*(global.maxpage+1),225);surface_set_target(sur);draw_clear_alpha(-1,0);//invertYes
repit=0;repeat(global.maxpage+1)
{if(repit<global.maxpage){draw_sprite(invertYes,repit+repit,(400*repit),0);draw_sprite(invertYes,repit+repit+1,(400*repit)+200,0);}
if(repit=global.maxpage)
{draw_sprite_ext(spr_temp2,0,(400*repit)+200,0,e*-1,f,0,-1,1);
draw_sprite_ext(spr_temp2,0,(400*repit)+600,0,e*-1,f,0,-1,1);
draw_sprite(invertYes,(2*repit)-1,(400*repit)-200,0);}
if repit<global.maxpage repit+=1;}
surface_reset_target();
spr2=sprite_create_from_surface(sur,0,0,400*(global.maxpage+1),225,0,0,0,0);
sprite_save_strip(spr2,"invertYes.png");surface_free(sur);
alarm[2]=70;
global.snapshot=0;
}
Code:
///Load saved pages
if(file_exists("spr_content.png"))
{sprite_replace(spr_content,"spr_content.png",global.maxpage+1,0,1,0,0);
sprite_replace(invertNo,"spr_content.png",(global.maxpage+global.maxpage)+2,0,1,0,0);
}
if(file_exists("invertYes.png"))
{sprite_replace(invertYes,"invertYes.png",(global.maxpage+global.maxpage)+2,0,1,0,0);
}
if sprite_exists(spr)sprite_flush(spr);
if sprite_exists(spr2)sprite_flush(spr2);
working=0;
//change to next background
bkg+=1;if bkg>4 bkg=0;
if bkg=0 background_index[0]=background0;
if bkg=1 background_index[0]=background1;
if bkg=2 background_index[0]=background2;
if bkg=3 background_index[0]=background3;
if bkg=4 background_index[0]=background4;
clickedBtn=0;
changed script from above spoiler to:
which then calls alarm1 just like the windows version:
[/CODE]
next the step event MAKE PAGE code is called:
which then calls alarm2 code:
And here is the image that is saved, note that it is all there like it should be, but it's not getting scaled down to fit the 400x225 sprite in the MAKE PAGE code action that runs after the surface is saved, even tho it does for windows!
Code:
surf = application_surface;
surface_set_target(surf);
surface_reset_target();
surface_save(surf,"savescreen.png");
alarm[1]=70;
surface_free(surf);
Code:
///get screenshot, start make pages
if(file_exists("savescreen.png"))
{sprite_replace(spr_temp,"savescreen.png",0,0,0,0,0);
sprite_replace(spr_temp2,"savescreen.png",0,0,0,0,0);
e=400/sprite_get_width(spr_temp);f=225/sprite_get_height(spr_temp);
global.snapshot=1;// activate the MAKE PAGE code in step event
}
next the step event MAKE PAGE code is called:
Code:
///MAKE PAGES
if(global.snapshot=1)
{global.maxpage+=1;
sur=surface_create(400*(global.maxpage+1),225);surface_set_target(sur);draw_clear_alpha(-1,0);//spr_content
for(var i=0;i<global.maxpage+1;i+=1;){if i<global.maxpage draw_sprite(spr_content,i,400*i,0);
if(i=global.maxpage){draw_sprite_ext(spr_temp,0,400*i,0,e,f,0,-1,1);
draw_set_color(c_blue);draw_text(((200+(400*i))-13),209,"("+string((i+1))+")");}
}
surface_reset_target();
spr=sprite_create_from_surface(sur,0,0,400*(global.maxpage+1),225,0,0,0,0);
sprite_save_strip(spr, "spr_content.png");surface_free(sur);
sur=surface_create(400*(global.maxpage+1),225);surface_set_target(sur);draw_clear_alpha(-1,0);//invertYes
repit=0;repeat(global.maxpage+1)
{if(repit<global.maxpage){draw_sprite(invertYes,repit+repit,(400*repit),0);draw_sprite(invertYes,repit+repit+1,(400*repit)+200,0);}
if(repit=global.maxpage)
{draw_sprite_ext(spr_temp2,0,(400*repit)+200,0,e*-1,f,0,-1,1);
draw_sprite_ext(spr_temp2,0,(400*repit)+600,0,e*-1,f,0,-1,1);
draw_sprite(invertYes,(2*repit)-1,(400*repit)-200,0);}
if repit<global.maxpage repit+=1;}
surface_reset_target();
spr2=sprite_create_from_surface(sur,0,0,400*(global.maxpage+1),225,0,0,0,0);
sprite_save_strip(spr2,"invertYes.png");surface_free(sur);
alarm[2]=70;
global.snapshot=0;
}
Code:
///Load saved pages
if(file_exists("spr_content.png"))
{sprite_replace(spr_content,"spr_content.png",global.maxpage+1,0,1,0,0);
sprite_replace(invertNo,"spr_content.png",(global.maxpage+global.maxpage)+2,0,1,0,0);
}
if(file_exists("invertYes.png"))
{sprite_replace(invertYes,"invertYes.png",(global.maxpage+global.maxpage)+2,0,1,0,0);
}
if sprite_exists(spr)sprite_flush(spr);
if sprite_exists(spr2)sprite_flush(spr2);
working=0;
//change to next background
bkg+=1;if bkg>4 bkg=0;
if bkg=0 background_index[0]=background0;
if bkg=1 background_index[0]=background1;
if bkg=2 background_index[0]=background2;
if bkg=3 background_index[0]=background3;
if bkg=4 background_index[0]=background4;
clickedBtn=0;
The only hint I have as to what's happening is that each time you save a page, the resulting image displayed on every page gets more and more magnified every time, what could be causing this??
Last edited by a moderator: