BookPage Turning-Function?

Started by Digital Mosaic Games, Fri 05/02/2010 12:51:00

Previous topic - Next topic

Digital Mosaic Games

I want to make a close-up view from a book where the player should be able to turn over pages.

My first idea to realize this function was that the player could move his mouse near to the border of a page and make the natural page-turning-move like when you turn a page with your hand only in this case with the mouse.
If anyone has an idea how to make this please tell me. I would respect this very much because I think AGS isn´t made for such difficult actions. :-\

My second(and easier) idea, because I think it´s really difficult for a scripter to realize opportunity 1, is that the mouse changes his Graphic/Mode into arrows when it is over the border and of the page. In my case every page is an object in the room. If the pages would be hotspots I would use the "mouse moves over hotspot-Function" but I don´t know how to make it with objects.
I thought of using something like that:

if(mouse.x==oPage1 && mouse.y==oPage1)  {
mouse.ChangeMode(eModeArrowLeft);}

And I don´t know in wich function I should put it.


Matti

A better way would be to make the book (or whatever it is) a GUI. Then you could just change the background image of the GUI depending on the page that is open. You could make the corner of the GUI/page a button to click on and make the page turn animation via changing the image.

GarageGothic

#2
Go with the easy idea. Trust me, I implemented Flash-like page turning in my game and it takes a lot of trigonometry as well as DrawingSurface functions running every game loop (due to AGS not supporting the same kind of masking as Flash). Probably I'll release a module once I untangle it from the rest of my code, but it won't be anytime in the near future.

I'd really say that what implementation would suit you depends a lot on how often this is used in-game as well as how many pages the books are supposed to have. If it's only one book and a handful of pages, and only readable in one room of the game, go with Objects. You can always code a more generic solution once you're more confident with scripting. (An alternative easy solution for a limited number of pages would be to use a room background for the book and use the frames of the background animation for the pages).

The function you're looking for is: Object.GetAtScreen(int x, int y)

So you would do:

Code: ags
if (Object.GetAtScreen(mouse.x, mouse.y) == oPage1) { 
  Mouse.Mode = eModeArrowLeft; //though probably you would rather want to keep the same mouse mode and use Mouse.ChangeModeGraphic instead 
  }


Edit: Wrote this before seeing Mr. Matti's post. GUIs are the best allround solution. I was trying to minimize the amount of scripting with my suggestions, but seeing as the interaction editor is no more, that's kind of pointless.

Digital Mosaic Games

#3
Quote from: GarageGothic on Fri 05/02/2010 13:40:13
The function you're looking for is: Object.GetAtScreen(int x, int y)

So you would do:

Code: ags
if (Object.GetAtScreen(mouse.x, mouse.y) == oPage1) { 
  Mouse.Mode = eModeArrowLeft; //though probably you would rather want to keep the same mouse mode and use Mouse.ChangeModeGraphic instead 
  }


In wich function would you put that code? There isn´t a function like "mouse moves over object".

GarageGothic

In the repeatedly_execute() function.

Digital Mosaic Games

Okay, now I have this code in repeadly execute() in my room.
Code: ags
if (Object.GetAtScreenXY(mouse.x, mouse.y) == oPage1) {
  aDoorClose.Play();
  }

For a test there should be my "close-door-sound" if the mouse is over "Page1".
But there happens nothing. :-\
That´s strange...

Calin Leafshade

have you set the rep ex function to be the rep ex function for that room?

You have to assign the function.

its in the same place as "enter room after fade in" and stuff like that.

Digital Mosaic Games

Yes, I have as you can see here:

Code: ags
function repeatedly_execute() { 

if (Object.GetAtScreenXY(mouse.x, mouse.y) == oPage1) {
  aDoorClose.Play();
  }
}
  

I know without writing this the game wouldn´t start. My game is working.
It´s only that than, when I move my mouse over "oPage1" nothing happens.
But there should be the sound.

monkey0506

Quote from: NEON-GAMES on Fri 05/02/2010 21:16:36I know without writing this the game wouldn´t start.

Wait, what??

...anyway...

The repeatedly execute function for rooms is different from every other script. You must open the room, click on the Events icon (the lightning bolt in the Properties pane) and then either a) type the name of a function, or b) click on the ellipses (...) button to create the function. The default name for the function is like room_RepExec() not repeatedly_execute. You can name it repeatedly_execute if you like, but unless it's the function listed in the Events for the room it will not be called.

Calin Leafshade

The exception to this is repeatedly_execute_always() which just needs to be named.. I dunno why theres an inconsistency there.

monkey0506

The inconsistency is because "repeatedly execute" was formerly implemented as part of the Interaction Editor (pre-3.0) whereas "repeatedly execute always" was never available outside of the script. ;)


Digital Mosaic Games

Hi,

Now I´ve used the repeadly_execute function and it works :)
But when I click on the first page(object which is called "oPage1") there should should be an event but nothing happens. ???
Maybe this don´t work because I use Verbcoin-Control in my game.

Digital Mosaic Games

It´s okay.
I´ve figured out my mistake.

SMF spam blocked by CleanTalk