This article will achieve the following results:
2In the previous article, we continue to make the hint function (hint through halo animation ). After clicking "hint", the player will be prompted by the halo on the screen:
2.1. Set the halo ImageFlare.pngAdd a project namedHintflareimageAnd drag it into layout:
2.2. Adjust the XAML of hintflareimage to run storyboard later:
< Image Height = "99.49" Width = "72.601" Canvas. Left = "365.074" Canvas. Top = "334.773"
Source = "Images/notepad.png" Stretch = "Fill" Rendertransformorigin = "0.5, 0.5" > < Image. rendertransform > < Transformgroup > < Scaletransform /> < Skewtransform /> < Rotatetransform /> < Translatetransform /> </ Transformgroup > </ Image. rendertransform > </ Image >
2.3. Add another two storyboards to mainpage. XAML,ShowhintstoryboardAndRotatehintstoryboardTo display and rotate the halo respectively:
< Storyboard X : Name = "Showhintstoryboard" Autoreverse = "True"> < Doubleanimationusingkeyframes Begintime = "00:00:00"
Storyboard. targetname = "Hintflareimage"
Storyboard. targetproperty = "(Uielement. opacity)"> < Easingdoublekeyframe Keytime = "00:00:00" Value = "0"/> < Easingdoublekeyframe Keytime = "00:00:02" Value = "0.8"/> </ Doubleanimationusingkeyframes > </ Storyboard >
< Storyboard X : Name = "Rotatehintstoryboard"> < Doubleanimationusingkeyframes Begintime = "00:00:00"
Storyboard. targetname = "Hintflareimage"
Storyboard. targetproperty = "(Uielement. rendertransform ).
(Transformgroup. Children) [2]. (rotatetransform. Angle) "> < Easingdoublekeyframe Keytime = "00:00:00" Value = "0"/> < Easingdoublekeyframe Keytime = "00:00:04" Value = "360"/> </ Doubleanimationusingkeyframes > </ Storyboard >
2.4. Add two new hinttextblockControlstoryboardactionThey will be used to execute showhintstoryboard and rotatehintstoryboard respectively:
3Finally, we can use behavior to control where the implied halo is displayed, add the class to the project, and compile it:
Return to blend and add it to usercontrol.Hintbehavior:
NewEventtrigger, Set hintoverlaynameHintflareimage:
Click hintitems collection to set the items to be hinted at. originx (y) variance indicates the location deviation between halo and Path:
RunProgramLet's see the effect,Source codeDownload:
Microsoft official expression blend Tutorial: Learn expression Blend