So, I got problems when I click on a label.
The label object clicks call this
private: System::Void GoSouth_Click(System::Object^ sender, System::EventArgs^ e) {
if (WhereAim != "South") {
LeggingPath = "C:\\Images\\SQSSPants.png";
TorsoPath = "C:\\Images\\SQSSShirt.png";
HeadPath = "C:\\Images\\SQSSFace.png";
WeaponPath = "C:\\Images\\SQSSSword.png";
ShieldPath = "C:\\Images\\SQSSWoodShield.png";
WhereAim = "South";
}
int CharX2;
int CharY2;
CharY2 = CharY +25;
if (CharY2 > 300) {
CharY2 = 300;
}
RefreshMap(true);
while (CharY2 > CharY) {
RefreshMap(false);
CharY = CharY +1;
}
}
Then
RefreshMap calls this
void RefreshMap(bool IfWhole) {
if (IfWhole == true) {
SpriteImage->BackColor = Color::Black;
}
SpriteImage->Paint += gcnew System::Windows::Forms::PaintEventHandler( this, &MainPlay::SpriteImage_Paint );
SpriteImage->Refresh();
if (IfWhole == true) {
delete SpriteImage->Image;
}
}
wich in turns calls this :
void SpriteImage_Paint( Object^ /*sender*/, System::Windows::Forms::PaintEventArgs^ e)
{
e->Graphics->Clear(Color::Black);
if (WhereAim == "South") {
e->Graphics->DrawImage(Legging, CharX, CharY, Legging->Width, Legging->Height);
e->Graphics->DrawImage(Torso , CharX, CharY, Torso->Width , Torso->Height );
e->Graphics->DrawImage(Head , CharX, CharY, Head->Width , Head->Height );
e->Graphics->DrawImage(Weapon , CharX, CharY, Weapon->Width , Weapon->Height );
e->Graphics->DrawImage(Shield , CharX, CharY, Shield->Width , Shield->Height );
}
if (WhereAim == "North") {
e->Graphics->DrawImage(Weapon , CharX, CharY, Weapon->Width , Weapon->Height );
e->Graphics->DrawImage(Shield , CharX, CharY, Shield->Width , Shield->Height );
e->Graphics->DrawImage(Legging, CharX, CharY, Legging->Width, Legging->Height);
e->Graphics->DrawImage(Torso , CharX, CharY, Torso->Width , Torso->Height );
e->Graphics->DrawImage(Head , CharX, CharY, Head->Width , Head->Height );
}
}
===============================================
So
I wanna know why each time I click on my label the movement of my character gets slower and slower...
(Can't be more concised heh?
A looped graphic refreshing function gets slower and slower
Started by FenixEden, Nov 09 2010 10:52 PM
2 replies to this topic
#1
Posted 09 November 2010 - 10:52 PM
|
|
|
#2
Posted 09 November 2010 - 11:44 PM
You add an event handler each time you call Refreshmap:
Therefore it updates your image first once then twice then trice etc. each time (this is what takes the time). You should instead put the above code in the load event or somewhere else where it just occur once.
SpriteImage->Paint += gcnew System::Windows::Forms:aintEventHandler( this, &MainPlay::SpriteImage_Paint );
Therefore it updates your image first once then twice then trice etc. each time (this is what takes the time). You should instead put the above code in the load event or somewhere else where it just occur once.
#3
Posted 10 November 2010 - 12:30 AM
So, How do I paint it more than once without paiting it twice than trice than 4x?
===EDIT===
....
Sorry...
Just understood that refresh did the job.
Thanks a lot
===EDIT===
....
Sorry...
Just understood that refresh did the job.
Thanks a lot


Sign In
Create Account

Back to top









