c#实现水波特效
很简单,就是调用罗云斌老师做好的DLL。
附上源码!
1
using System;2
using System.Collections.Generic;3
using System.ComponentModel;4
using System.Data;5
using System.Drawing;6
using System.Text;7
using System.Windows.Forms;8
using System.Runtime.InteropServices;9

10
namespace water11


{12
public partial class Form1 : Form13

{14
public Form1()15

{16
InitializeComponent();17
}18

19
[DllImport("Wave.dll")]20
public static extern int E_WaveInit(IntPtr hwnd, string bmpStr);//初始化对象21
[DllImport("Wave.dll")]22
public static extern int E_AutoEffects(int type, int type1, int type2, int type3);//效果类型23
[DllImport("Wave.dll")]24
public static extern int E_WaveDropStone(int x,int y,int dx,int zl);//仍石头25
[DllImport("Wave.dll")]26
public static extern void E_WaveFree();//释放对象27

28
Random r = new Random();//置随机数种子29

30
private void Form1_Load(object sender, EventArgs e)31

{ 32
E_WaveInit(this.Handle, Application.StartupPath + "\\wave.bmp");33
E_AutoEffects(2,0,0,0); 34
}35

36
private void btnXY_Click(object sender, EventArgs e)37

{38
E_AutoEffects(1, r.Next(3, 25), r.Next(0, 5), r.Next(50, 250));39
}40

41
private void btnCZ_Click(object sender, EventArgs e)42

{ 43
E_AutoEffects(2, r.Next(3, 7), r.Next(1, 5), r.Next(100, 500));44
}45

46
private void btnFL_Click(object sender, EventArgs e)47

{48
E_AutoEffects(3, r.Next(50, 300), r.Next(2, 5), r.Next(5, 10));49
}50

51
private void btnStop_Click(object sender, EventArgs e)52

{53
E_AutoEffects(0, 0, 0, 0);54
}55

56
private void btnDispos_Click(object sender, EventArgs e)57

{58
if (btnDispos.Text == "卸载")59

{60
E_WaveFree();//释放资源61
btnDispos.Text = "加载";62
}63
else64

{65
E_WaveInit(this.Handle, Application.StartupPath + "\\wave.bmp");66
btnDispos.Text = "卸载";67
}68

69
}70

71
private void btnExit_Click(object sender, EventArgs e)72

{73
E_WaveFree();//释放资源74
Application.Exit();75
}76

77
private void Form1_MouseMove(object sender, MouseEventArgs e)78

{79
E_WaveDropStone(e.X, e.Y, r.Next(0, 5), r.Next(300, 800));80
}81

82
private void Form1_MouseDown(object sender, MouseEventArgs e)83

{84
E_WaveDropStone(e.X, e.Y, r.Next(0, 5), r.Next(300, 800));85
}86
}87
}88

这里没有做过多的解释,菜鸟的人也可以看懂!
需要源码的话,请点击这里下载

浙公网安备 33010602011771号