MODULE: Panorama v1.6

Started by Kweepa, Sat 29/07/2006 19:14:25

Previous topic - Next topic

InfernalGrape

Some more adventures I have with attempt of continued work with Panorama 1.6 (haha!).

I was trying to get this working:
Code: ags
To have cursors change when over objects and hotspots, use
  Panorama.SetCursorMapping(mouseMode, nonAnimatedCursor, animatedCursor);
For example, to have the "Look at" cursor change:
  Panorama.SetCursorMapping(eModeLookat, eModeLookat, eModeLookAtAni);
where "LookAtAni" is a new cursor animated using a view.
Don't use the "Only when over a hotspot or object" checkbox on the
cursors as this will interfere with Panorama's behaviour.

However, I was not getting results.
In PanoramaDemo (which uses Panorama 1.2) it works though.

Anyway, currently I just decided to ignore this problem and instead went with simpler option like this (based on example I found on forum):
Code: ags
  if (Hotspot.GetAtScreenXY(Panorama.GetBackgroundXForMouseX(mouse.x), Panorama.GetBackgroundYForMouseXY(mouse.x, mouse.y)) != hotspot[0])
    {
    mouse.SaveCursorUntilItLeaves();
    mouse.UseModeGraphic(eModePntrAni);
    }

It works for me... though for some reason I can't make it use animation/view for cursor, so for now it's just a simple sprite change when hovering over hotspot - which satisfies me for the current moment.

But if anyone would be fiddling with it and succeeds more, please let me know...

Cheers  :grin:

Khris

#101
@InfernalGrape

This requires tracking the state, otherwise you will set the graphic 40 times per second and thus the animation never has a chance to run.

Code: ags
// above repeatedly_execute
LocationType prevLT;

  // inside repeatedly_execute
  int x = Panorama.GetBackgroundXForMouseX(mouse.x);
  int y = Panorama.GetBackgroundYForMouseXY(mouse.x, mouse.y);
  int lt = GetLocationType(x, y);

  if (lt != eLocationNothing && prevLT == eLocationNothing) {
    // mouse moved over active area
    mouse.UseModeGraphic(eModePntrAni);
  }
  else if (lt == eLocationNothing && prevLT != eLocationNothing) {
    // mouse moved outside active area
    mouse.UseModeGraphic(eModeLookAt);
  }
  prevLT = lt;

InfernalGrape

#102
Thank you for suggestion!

However, when I tried using it, I ended up having errors (like "undefined symbol" in log output of AGS).
And when I tried to fix it (which was wrong, I'm sure, as i was trying to add those ints into header following some old examples with export/import lines), I got even more errors and gave up (don't forget I never was a coder, so all I do is looking for examples and trying to adapt them).

I guess this stuff is still a bit too advanced for me, so I'll try returning to it later perhaps.
But thanks for help, of course.

Khris

This is not really advanced in any sense. If you got an error message, please tell us the exact message and the line it is pointing to. It's probably the cursor mode, which is called "eModeLookat" with a lowercase "a".

(Also, when code I post is supposed to go into the header, it usually says so in or above the relevant part.)

Other people might be reading this and wanting to use the code I posted, but I can't fix it because I haven't set up a panorama game, and I'm way too lazy to do that just to fix a basic typo.
Don't be afraid to do some very basic debugging.

InfernalGrape

#104
Ok, I've tried again.

So, the placement is
Code: ags
function game_start()
{
 LocationType prevLT;
}

And

Code: ags
function repeatedly_execute_always()
{
  int x = Panorama.GetBackgroundXForMouseX(mouse.x);
  int y = Panorama.GetBackgroundYForMouseXY(mouse.x, mouse.y);
  int lt = GetLocationType(x, y);

  if (lt != eLocationNothing && prevLT == eLocationNothing) {
    mouse.UseModeGraphic(eModePntrAni);
  }
  else if (lt == eLocationNothing && prevLT != eLocationNothing) {
    mouse.UseModeGraphic(eModeLookAt);
  }
  prevLT = lt;
}

Right?
With that, I'm getting following error:
Code: ags
GlobalScript.asc(22): Error (line 22): undefined symbol 'prevLT'

Same results (with error referencing different line number) if putting 2nd part of code into rep.ex. instead of rep.ex.always portion of global script.

EDIT:

Ok, I've now tried to put " LocationType prevLT;" literally above rep.ex. block, outside of any of event partition blocks.
That gets rid of error, but also doesnt provide a working result of cursor change in game.  Later I also tried to bring back code from my post above to see if they work together, but guess your solution was meant to be independantly working.

Khris

Yeah, the line is supposed to be outside any function. I always indent my lines correctly so you can just copy-paste them.

My code should do all the work on its own; a basic way to test it is to add a Display("changing mode"); line inside the first if-block.

InfernalGrape

@Khris

Thanks. I feel like we're getting closer to truth.

Believe it or not, when I've added Display test where you've said, something happened.
The following took place: when I moved mouse over hotspot, that very message appeared and during that message the cursor was depicted as needed one (I've removed animations currently, but I still kept different sprite so I can confirm it was changed).

Then I removed Display line again, and tried to pay more attention to what happens.
Then I realized... it looks like, the change we try to achieve happens very briefly (like for one frame or something, during the very moment when cursor crosses the border between hotspot and non-hotspot part of screen) and then nullifies.
Like, I if focus my eyes I can see cursos being changed to the one it should be, however it happens with a blink of eye and goes back even though cursor position is still on top of hotspot.

Perhaps this might give you more ideas of what could be changed to fix it...
Thanks much for not letting it go and having patience to get report from me.

Khris

This sounds like you still have code elsewhere that resets the cursor. My own code only changes the cursor back when you move the mouse off the hotspot. Maybe check the room_RepExec?

InfernalGrape

#108
Contents of room_RepExec are these, and they are needed to get things of Panorama to work (at least in my experience so far):

Code: ags
Panorama.StandardLookAround(mouse.x);
Mouse.EnableMode(eModePointer);
Mouse.Mode = eModePointer;
Mouse.Visible = true;

Yeah, I'm currently using eModePointer as default cursor, which is why I smiled a bit when you talked about LookAt in you example, and of course I was rewriting it back to Pointer in that case.
So, eh, the "Mouse.Mode = eModePointer; " should be culprit? I'll try moving it to load room or load game event and check... thanks...

EDIT:

Wow! @Khris thank you very much again. Looks like it was really a silly mistake of me putting cursor type choice in room_RepExec.
Now it finally works (also perhaps it was the reason I was not getting results with Module-native solution of SetCursorMapping function... will check that later).
I feel akwards now, but hopefully this might help others in case they'd do same wrong decisions as me... Learning is always a curved road, isnt it...

p.s.

I'm still wondering why my mistake placement was not affecting option from post #100 though (the one that won't allow animation, but still worked for cursor change... is it because mouse.SaveCursorUntilItLeaves is such a strong thing?).

Khris

These lines are all setup lines, with the exception of the first (I guess). They are supposed to go into room_Load, not room_RepExec, because they only need to be called once, not 40 times per second.

The animation didn't work because you were resetting the cursor to the animated one during every game loop, i.e. also 40 times per second. Each time you do that, AGS wants to start the animation, then 0.025 seconds later you tell it again to start the animation. It never has the chance to actually play it to its second frame.

Kweepa

Thanks everyone for being tech support for my module :=
And don't worry LimpingFish, I wasn't too bothered that hardly anyone ended up using it. I had fun coding it...
Still waiting for Purity of the Surf II

SaaviWorld

Hey, guys. Go easy on me, coding isn't my strong suit. I'm just trying to get a basic cylindrical room running with v1.6. I followed the manual's instructions. Currently using AGS 3.6.1.


Below is the error I received:

room1.asc(5): Error (line 5): '.UseSpriteAsBackground' is not a public member of '__Panorama'. Are you sure you spelt it correctly (remember, capital letters are important)?


Let me know if I'm missing something.

SMF spam blocked by CleanTalk