C#实现气泡
来源:互联网 发布:vb小写数字转大写金额 编辑:程序博客网 时间:2024/04/30 04:34
本节主要讲解气泡,代码如下
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Threading.Tasks;using System.Windows.Forms;//导入的命名空间using System.Drawing.Drawing2D;namespace 气泡{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { //设置窗体的属性,注释部分为可省略部分 this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; // this.BackColor = Color.Red; // this.Opacity = 0.7; this.Width = this.Height = 100; // this.Location = new Point(0,0); //使之呈现圆形,此处需要导入命名空间System.Drawing.Drawing2D; GraphicsPath Gp = new GraphicsPath(); Gp.AddEllipse(0,0,100,100); this.Region = new System.Drawing.Region(Gp); //控制气泡的移动的Timer函数,可在编辑界面直接拖入,也可在后台定义 timer1.Start(); //多个气泡只要实例化更多的窗体就行,代码和这个窗体的一样 // Form2 form = new Form2(); // form.Show(); } //定义x,y为X轴,Y轴方向速度 int x=10, y=10 ; private void timer1_Tick(object sender, EventArgs e) { //如果碰到屏幕的上面或者下面,那么y轴方向速度变为相反数,x轴方向速度不变,反之亦然 if (this.Bottom>=Screen.PrimaryScreen.WorkingArea.Height||this.Top<0) { y = -y; } if (this.Left<0||this.Left+this.Width>=Screen.PrimaryScreen.WorkingArea.Width) { //此处通过绝对路径导入图片,但最好是相对路径,可确保移动文件时能找到相应的地址 this.BackgroundImage = Image.FromFile(@"G:\练习\气泡1\气泡1\Image\1e70f0ab227242acacee12c82645b44a_sihuosheng-001.jpg"); x = -x; } this.Left += x; this.Top += y; } }}
通过气泡游戏,可以学到关于窗体的一些属性的设置,Timer空间的使用,以及C#的一些基础的语法
多个气泡相撞的判断,等价于圆心距离的判断
0 0
- C#实现气泡
- c#实现任务栏气泡提醒
- C# WinForm实现气泡提示效果
- c# winform实现气泡提示窗口
- c# winform实现气泡提示窗口
- C# 实现托盘,并显示气泡消息
- 在C#中实现系统拖盘处的气泡提示
- c# winform 如何实现弹出气泡状的提示框
- 在C#中实现系统拖盘处的气泡提示
- c# winform 如何实现弹出气泡状的提示框
- C#中实现类似QQ的气泡提示
- C# 气泡提示方法
- swt复杂气泡实现
- 气泡效果的实现
- C语言实现气泡
- css实现气泡对话框
- 聊天气泡效果实现
- android实现气泡聊天
- linux useradd(adduser)命令参数及用法详解(linux创建新用户命令)
- JAVA基础:String, StringBuffer, StringBuilder ——区别,用法及常见问题
- 【jzoj4755】【快速荷叶叶变换】
- Struts2的配置文件标签详解
- Spark Standalone 内部原理(一)
- C#实现气泡
- 一些数列
- 知识图谱和Neo4j图数据库
- jquery+ajax
- LeetCode #188: Best Time to Buy and Sell Stock IV
- GCD/扩展欧几里得
- 方向分割
- 时间、日期格式化技巧
- 摄像机目标渲染纹理targetTexture