Dialog box and animation questions

Started by Eric, Sat 03/05/2014 20:36:50

Previous topic - Next topic

Eric

...So I've finally gotten together enough art assets that I'm forcing myself to start programming a game. I've got two questions, probably the first of many to come, with apologies if these are obviously simple, and with appreciation for your time and guidance.

Question 1:
I'm trying to move a Sierra-style portrait system to the bottom of the screen, as I've created backgrounds with a lot of foot room, and not as much head room (so heads of characters were constantly blocked by the dialog box). I've successfully done so, using Crimson Wizard's recent addition to 3.3.0, Speech.CustomPortraitPlacement (thank you, CW!).

The portrait's now in the right place, but the accompanying dialog box still aligns to the top of the portrait. Since it's at the bottom of the screen, I'd like the text box to align with the baseline of the portrait (which I've set to be 15 pixels from the bottom of the screen).

Is that possible?

Question 2:
Now that the heads are visible, I am curious as to whether it would be possible for there to be an additional talking animation to be played for the character's non-portrait, walking-around sprite. I'll be lip-syncing the portrait (hopefully with voice tracks), but the sprite can just have a simple loop of three mouth movement frames.

Is that possible?

Thanks again!

Gurok

#1
I'm not sure about question 1. To move my text GUIs down a few pixels, I used top borders that were padded with about 10 pixels of transparency. Actually moving the boxes around might be possible, but I haven't discovered how.

I think I can help you with question 2 though. This is roughly how I did it:

Code: ags

// In header (e.g. Character.ash)
#define Character_ANIMATE_DELAY  4

bool  Character_Initialised;
int   Character_Chat[ ];
bool  Character_Spoken[ ];

import function SetChatView(this Character *, int chat);

// In module (e.g. Character.asc)
function InitialiseCharacter()
{
	if(!Character_Initialised)
	{
		Character_Initialised = true;
		Character_Chat = new int[Game.CharacterCount];
		Character_Spoken = new bool[Game.CharacterCount];
	}

	return;
}

function SetChatView(this Character *, int chat)
{
	InitialiseCharacter();
	Character_Chat[this.ID] = chat;

	return;
}

function repeatedly_execute_always()
{
	int index;
	bool speaking;

	InitialiseCharacter();
	index = Game.CharacterCount;
	while(index > 0)
	{
		index--;
		if(character[index].Room == player.Room)
		{
			speaking = character[index].Speaking && character[index].SpeakingFrame > 0;
			if(speaking)
			{
				if(!Character_Spoken[index])
				{
					character[index].LockView(Character_Chat[index]);
					character[index].Animate(character[index].Loop, Character_ANIMATE_DELAY, eRepeat, eNoBlock);
				}
			}
			else
				if(Character_Spoken[index])
					character[index].UnlockView();
			Character_Spoken[index] = speaking;
		}
	}

	return;
}


I tend to extend the built-in objects where I can. In your game_start(), you can just call something like this:

Code: ags
cFred.SetChatView(FREDCHAT);


If you have 2-3 frames of chat animation for your walking sprites, this will work really well. It starts when the portrait starts talking and stops when the portrait stops, so if you have pauses at the end of your dialogue, the characters won't go on chatting while the portrait is paused. Hope this helps!

Oh, I might add. I tried this, but found it visually confusing in the end. It's odd, but when both the portrait and the regular view are animated at once, your eye is drawn to two places, one of them not where the text is.
[img]http://7d4iqnx.gif;rWRLUuw.gi

Eric

That works brilliantly, Gurok! Thank you!

Quote from: Gurokfound it visually confusing in the end. It's odd, but when both the portrait and the regular view are animated at once, your eye is drawn to two places, one of them not where the text is.

I suppose I'll find this out in letting others test, eventually, but one of my motivations is that my sprites are hi-res and generally pretty big on the screen, so it doesn't look right to me for the character to sit idle. But this is a good thing to keep in mind. Thank you!

SMF spam blocked by CleanTalk