Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - Vera

#1
I need a little help getting part of this script to work. Here's some info that may or may not be more than needed... if so just skip to The Problem toward the bottom of my post.

The GUI:
I have a particular GUI that only shows up in one room, since it's a New/Load/Delete Game type of thing. So, the GUI automatically appears upon entering that room, and doesn't appear anywhere else.

The Buttons:
Not all the buttons are initially visible.
At first, all you see is 3 buttons that represent the 3 different save slots (whose graphics vary depending on if the slot is used or empty), a DELETE button (for deleting previously saved files), a QUIT button, and finally a button at the top (that doesn't actually do anything, but it's image graphic tells the player what to do).

The buttons not initially visible are 3 buttons that determine which save slot to delete, an OK button (which confirms the deletion), and a different QUIT button (which cancels the deletion & takes you back to the main selections).

What I'm trying to achieve:
When you click on the DELETE button, the 3 "New/Load" buttons + the "Delete" button + the "Quit" button all go invisible. At the same time, the "does nothing" button at the top gets its normal graphic changed and is repositioned. Also, the 3 "Delete this Slot" buttons become visible.

Now the player can click one of the 3 "Delete this Slot" buttons. Then they go invisible, the top "does nothing" button changes its normal graphic again, and the "OK" + "Quit/Cancel" buttons appear.

Then the player can click OK to delete that file, or QUIT to return to the original selections (New/Loadx3 + Erase + Quit).

All the buttons (except the "does nothing" button at the top) are supposed to animate on mouse-over.

------------------------------------------

This is the code I have in my Global Script concerning this GUI's "Erase" button:

Code: ags
// STARTUP GUI - Erase File (Erase Button)
function btnEraseSave_OnClick(GUIControl *control, MouseButton button)
{
  btnSaveSlot1.Visible = false;
  btnSaveSlot2.Visible = false;
  btnSaveSlot3.Visible = false;
  btnEraseSave.Visible = false;
  btnCancelSave.Visible = false;
  btnChooseFile.NormalGraphic = 81;
  btnChooseFile.SetPosition(50, 0);
}


This is the code I have in the Room Script:

At the top of the room's script:
Code: ags
bool File1Animating;
bool File2Animating;
bool File3Animating;


In the room's RepExec function:
Code: ags
  // Show FILE selection if ERASE is clicked on
  if (btnChooseFile.NormalGraphic == 81) {
    btnFile1.Visible = true;
    btnFile2.Visible = true;
    btnFile3.Visible = true;
  }
  else {
      btnFile1.Visible = false;
      btnFile2.Visible = false;
      btnFile3.Visible = false;
  }
  // File 1 ANIMATION
  if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnFile1) {
    if(File1Animating == false) {
      btnFile1.Animate(8, 0, 5, eRepeat);
      File1Animating = true;
    }
    else {
      btnFile1.NormalGraphic = 85;
      File1Animating = false;
    }
  }
  // File 2 ANIMATION
  if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnFile2) {
    if(File2Animating == false) {
      btnFile2.Animate(12, 0, 5, eRepeat);
      File2Animating = true;
    }
    else {
      btnFile2.NormalGraphic = 130;
      File2Animating = false;
    }
  }
  // File 3 ANIMATION
  if (GUIControl.GetAtScreenXY(mouse.x, mouse.y) == btnFile3) {
    if(File3Animating == false) {
      btnFile3.Animate(13, 0, 5, eRepeat);
      File3Animating = true;
    }
    else {
      btnFile3.NormalGraphic = 141;
      File3Animating = false;
    }
  }


That's supposed to check if the "does nothing" button has a certain graphic (a "Delete which file?" image) then the 3 "Delete this file" buttons are shown (File 1, File 2, File 3).

------------------------------------------

The Problem
The 3 buttons that appear to allow the player to select which slots to delete DO appear as they should, BUT they won't animate correctly on mouse-over. They flicker. I think I've read somewhere about people experiencing this animation flicker, but I'm not sure how to fix my script specifically. Do I need to move some code around? Is it because some of the GUI's script is only in the room script, and some is in the global script? Because I wasn't really sure what should go where, since this GUI will only be appearing in this one room. Or perhaps it has something to do with the RepExec?

Any suggestions would be appreciated. Thank you!
#2
I feel like I'm doing something very stupid, like making a spelling error, but I've gone over this and I can't figure out why it's not working. Perhaps a fresh pair of eyes will help?

The player is taken to room 2 from room 1. The player's character isn't shown because this is a start up menu type of thing. After fade in, an object should appear and animate continuously in the background while a GUI (with no background image or border, just buttons!) shows some buttons you can click on to do some stuff.

Here's my code:

Code: ags
// room script file


function room_AfterFadeIn() {
  oNewLoadBG.Visible = true;
  oNewLoadBG.SetView(5, 0, 0);
  oNewLoadBG.Animate(0, 5, eRepeat, eNoBlock);
  gStartUp.Visible = true;
  gStartUp.BackgroundGraphic = 0;
  }


FYI - oNewLoadBG is the name of my object I want to show and animate. It is actually the same size as my background. I want it to ACT AS my background since I can have more animating frames with an object than I can with the actual background.

I want this object to animate while the GUI is up. The only thing visible on the GUI should be the buttons, so the whole thing should appear as a pretty animating background scene with some buttons laying on top.

THE PROBLEM

Nothing inside the function works. It won't even make the object visible, let alone animate. Am I missing something in my code? Is there something elsewhere in my game that could be blocking everything in this function? Any suggestions on what to be aware of that might interfere with it would be very helpful.
#3
I'm having trouble getting one part of my script to run.

This first room is just my title screen room. It scrolls and such like I want it, that part works fine. However, after the initial cutscene ends, I want the player to have to press ENTER in order to continue to the next room where gameplay actually begins and they can control the character and such.

So I believe I need to use the on_key_press function within this room. Unfortunately, since I'm new to this, I seem to be messing up bracket placements and such.  When I try to test the room, I get an error around line 21, which is where the on_key_press function is.

Here's my full script for this room:

Code: ags
// room script file

  
function room_AfterFadeIn()
{
StartCutscene(eSkipESCOnly);
  int ypos = 0;
while (ypos < 120) {
  SetViewport(0, ypos);
  Wait(4);
  ypos = ypos +1;
}
{
EndCutscene();
oTitle.Visible = true;
oPressEnter.Visible = true;
object[1].SetView(3);
object[1].Animate(0,  3, eRepeat);
}

function on_key_press(eKeyCode keycode)
{
  if (keycode == eKeyReturn)
  {
    player.ChangeRoom (2, 130, 120);
    ClaimEvent();
  }
}
}


As I said, the first part of the script works fine; the issue I'm having is with the on_key_press function not running. If anyone can spot my error, it would be a great help.

Thank you.
#4
So I registered today just to ask about this. I've searched all over the forums and the manual and everywhere I can think of for the past couple days, and I can't figure this out.

I have a 320x240 game. I imported a 320x343 background. As of right now I have no characters yet, and for this room (my Intro/Title Screen room) I have ShowPlayerCharacter set to False.

Here's what I'm trying to achieve:

I want the game to fade in, showing the top portion of the background.

After a sec, the background begins to slowly scroll down. (A plus would be if I could adjust this speed to my liking)

Then, after a moment, my Title Image appears.
(Oh, and I also threw in a cutscene script so I can just skip to the Title Image)

The script I have currently:

Code: ags
// room script file

function room_AfterFadeIn()
{
StartCutscene(eSkipESCOnly);
int ypos = 0;
while (ypos < 120) {
  SetViewport(0, ypos);
  Wait(4);
  ypos = ypos +1;
}
{
EndCutscene();
oTitle.Visible = true;
}
}


My problem with this script:

What it's doing is showing the 320x240 view somewhere in the middle of my background for just a moment, then it jumps up to the top of the background and starts scrolling down. This jump is driving me nuts. It looks bad. I need it to just start at the top, not the middle.

How I tried fixing it

A.)   If I change this part...

Code: ags
int ypos = 0;


...to this:

Code: ags
int ypos = 40;


Then the jump no longer occurs. However, it also stops scrolling from the very top. It just starts the scroll down further, not showing the top part of my BG at all. No good!

B.)   I thought it might have something to do with the room's edges. BottomEdgeY, TopEdgeY... I messed around with those and it did nothing. After researching, I guess this only has to do with the character. No good!

Conclusion:

So I guess what I need is a way to set the view of the room to the top when it loads, instead of the middle, so that when it begins the scroll downward, it doesn't show the middle, jump up top, then scroll down. I'm sure I'm missing something obvious and silly, but if anyone could help with this part of my script or at least point me in the right direction, it would help greatly.

Thanks!
SMF spam blocked by CleanTalk