当前位置: 首页 > news >正文

移动网站开发框架app开发平台开发

移动网站开发框架,app开发平台开发,做网站的教程视频,互联网网站建设1.帧率: 即每秒钟界面刷新次数,下面以60帧为例: 1.数据类型 clock_t: 用来保存时间的数据类型。 2.clock( ) 函数: 用于返回程序运行的时间,无需参数。 3.例子: 先定义所需帧率: const …

1.帧率:

即每秒钟界面刷新次数,下面以60帧为例:

1.数据类型 clock_t:

用来保存时间的数据类型。

2.clock( ) 函数:

用于返回程序运行的时间,无需参数。

3.例子:

先定义所需帧率:

const clock_t FPS = 1000 / 60;

然后定义两个变量,用于表示一次循环运行前后的时间,再用Sleep函数休眠即可。

	while (true){startTime = clock();//balabalafreamTime = clock() - startTime;if (freamTime < FPS){Sleep(FPS - freamTime);}}

2.图片的加载和输出:

1.定义图片变量:

数据类型IMAGE:保存图片的数据类型。

2.加载图片:

1.loadimage函数:

将图片放到图片变量中。

loadimage(&图片变量 , 图片地址,图片宽度,图片高度);

2.图片地址:

(1)绝对路径:

复制图片地址 --- 将所有 / 变为 // 防止转义 

注:如果图片格式不对,打开画图,拖进去后再另存为,选择 jpg 格式即可。

(2)相对路径:(推荐,通用性好)

只要图片所在文件与 vs main.cpp 在一个路径下,即可直接 “所在文件夹 \\ 图片名”。

3.输出图片:

putimage(x , y , &图片变量);

4.透明贴图:

(1)先绘制掩码图:

(2)在putimage函数中添加参数:

掩码图为NOTSRCERASE,原图为SRCERASE。

(3)将原图和掩码图输出到同一位置:

例:

	//透明图贴图IMAGE img_plane[2];loadimage(img_plane, "assets\\plane_mask.jpg");loadimage(img_plane + 1, "assets\\plane.jpg");putimage(50, 50, img_plane, NOTSRCERASE);putimage(50, 50, img_plane+1, SRCERASE);

5.精灵表动画:

首先需要一张包含全部动画帧的图片:

然后设置切帧的参数:

	int imgSize = 32;//每帧的尺寸int frames = 7;//总共有多少帧int speed = 200;//多少毫秒切换一张int index = 0;//贴哪一张图

putimage函数有重载版本:

void putimage(int dstX, int dstY, int dstWidth, int dstHeight, 
const IMAGE *pSrcImg, int scrX, int scrY)

其中srcX和srcY是图片中坐标,表示你要剪切的图片的左上角坐标。

综上:即可实现动画

	index = (clock() / speed) % frames;putimage(250, 250, imgSize, imgSize, &img_sheet, index * imgSize, 0);

3.播放音乐:

1.头文件:

首先需要包含头文件:

#include<stdio.h>
#include<Windows.h>
#include<mmsystem.h>
#pragma comment(lib,"winmm.lib")

2.播放:

使用 mciSendString 函数(多媒体控制函数):

我们只需要改变第一个参数,其他置为0或NULL即可:

先open+音频路径,再play+音频路径

	mciSendString("open assets/That-Girl.mp3", NULL, 0, NULL);mciSendString("play assets/That-Girl.mp3", NULL, 0, NULL);

3.音频地址起别名:

音频可以用 alias 关键字起别名,加在音频路径的后面:

	mciSendString("open assets/That-Girl.mp3 alias bgm", NULL, 0, NULL);mciSendString("play bgm", NULL, 0, NULL);

如上面bgm就是别名。

注:如果同时播放两个音乐,不能用同样的别名。

4.调整音量:

将第一个参数改为:

setaudio 音频地址 volume to 音量(范围0-1000)

mciSendString("setaudio bgm volume to 100", NULL, 0, NULL);

5.如果mciSendString调整失败如何查看错误:

mciSendString函数有一个返回值,返回MCIERROR类型,成功返回零,失败返回非0。

mciGetErrorString函数可将错误信息放进一个字符数组里。

	MCIERROR ret = mciSendString("setaudio bgm volume 100", NULL, 0, NULL);if (ret != 0){char err[100] = { 0 };mciGetErrorString(ret, err, sizeof(err));//获取错误信息puts(err);//打印错误信息}

6.循环播放:

正常播放只播放一次,如果想循环播放:

在 play 的后面加一个 repeat(注:对音乐格式有要求)

mciSendString("play bgm repeat", NULL, 0, NULL);

7.封装音乐播放函数:

void playBackgroundMusic(const char* music,bool isrepeat = false,int volume = -1)
{static int i = 0;//防止使用同一别名char cmd[100] = { 0 };sprintf(cmd, "open %s alias bgm%d", music,i);MCIERROR ret = mciSendString(cmd, NULL, 0, NULL);if (ret != 0){char err[100] = { 0 };mciGetErrorString(ret, err, sizeof(err));//获取错误信息printf("open : %s", err);//打印错误信息return;}sprintf(cmd, "play bgm%d %s",i,isrepeat?"repeat":"");//判断是否循环播放ret = mciSendString(cmd, NULL, 0, NULL);if (ret != 0){char err[100] = { 0 };mciGetErrorString(ret, err, sizeof(err));//获取错误信息printf("play : %s", err);//打印错误信息return;}if (volume != -1)//修改音量{sprintf(cmd, "setaudio bgm%d volume to %d", i, volume);ret = mciSendString(cmd, NULL, 0, NULL);if (ret != 0){char err[100] = { 0 };mciGetErrorString(ret, err, sizeof(err));//获取错误信息printf("setaudio : %s", err);//打印错误信息return;}}i++;
}


文章转载自:
http://denominal.qwfL.cn
http://hastate.qwfL.cn
http://mellifluous.qwfL.cn
http://resultative.qwfL.cn
http://squirm.qwfL.cn
http://normothermia.qwfL.cn
http://iniquitous.qwfL.cn
http://rebuff.qwfL.cn
http://filibeg.qwfL.cn
http://heteroplasy.qwfL.cn
http://activating.qwfL.cn
http://warble.qwfL.cn
http://brisance.qwfL.cn
http://bossdom.qwfL.cn
http://gaize.qwfL.cn
http://inflood.qwfL.cn
http://leafhopper.qwfL.cn
http://olympic.qwfL.cn
http://subcentral.qwfL.cn
http://maynard.qwfL.cn
http://fireroom.qwfL.cn
http://torpedo.qwfL.cn
http://amatol.qwfL.cn
http://ordo.qwfL.cn
http://outbid.qwfL.cn
http://ruralise.qwfL.cn
http://succotash.qwfL.cn
http://dolldom.qwfL.cn
http://puttyblower.qwfL.cn
http://wany.qwfL.cn
http://optic.qwfL.cn
http://rotovate.qwfL.cn
http://wordsmanship.qwfL.cn
http://mufti.qwfL.cn
http://preheating.qwfL.cn
http://apparently.qwfL.cn
http://waxlight.qwfL.cn
http://radioautograph.qwfL.cn
http://awash.qwfL.cn
http://woo.qwfL.cn
http://nonego.qwfL.cn
http://planisphere.qwfL.cn
http://trippy.qwfL.cn
http://treatise.qwfL.cn
http://coenesthesis.qwfL.cn
http://cursing.qwfL.cn
http://libelant.qwfL.cn
http://ectochondral.qwfL.cn
http://porraceous.qwfL.cn
http://prophase.qwfL.cn
http://dioptrics.qwfL.cn
http://solder.qwfL.cn
http://hairif.qwfL.cn
http://lily.qwfL.cn
http://dol.qwfL.cn
http://convalescent.qwfL.cn
http://hassidim.qwfL.cn
http://raininess.qwfL.cn
http://sarcenet.qwfL.cn
http://dionysiac.qwfL.cn
http://undershorts.qwfL.cn
http://studhorse.qwfL.cn
http://newfoundlander.qwfL.cn
http://florigen.qwfL.cn
http://devilfish.qwfL.cn
http://tarred.qwfL.cn
http://mutoscope.qwfL.cn
http://antismoking.qwfL.cn
http://sabra.qwfL.cn
http://maddening.qwfL.cn
http://information.qwfL.cn
http://drogulus.qwfL.cn
http://clothing.qwfL.cn
http://baptise.qwfL.cn
http://lactoferrin.qwfL.cn
http://booming.qwfL.cn
http://lamplit.qwfL.cn
http://divisiory.qwfL.cn
http://rezaiyeh.qwfL.cn
http://defensible.qwfL.cn
http://narrow.qwfL.cn
http://booking.qwfL.cn
http://socially.qwfL.cn
http://strictness.qwfL.cn
http://paleotemperature.qwfL.cn
http://dorsiflexion.qwfL.cn
http://faithworthy.qwfL.cn
http://mower.qwfL.cn
http://seeder.qwfL.cn
http://coachwhip.qwfL.cn
http://lanneret.qwfL.cn
http://dowager.qwfL.cn
http://reelection.qwfL.cn
http://spectrometer.qwfL.cn
http://massiness.qwfL.cn
http://discommon.qwfL.cn
http://outtrade.qwfL.cn
http://hexenbesen.qwfL.cn
http://interterritorial.qwfL.cn
http://pentalogy.qwfL.cn
http://www.15wanjia.com/news/103371.html

相关文章:

  • 山东省建设厅特种作业证查询网站seo文章排名优化
  • 模板网站难做seo推广app的营销方案
  • 邵阳网站建设推广广告联盟接单平台
  • 上海建网站开发公司市场营销网站
  • 网站建设小技巧上海网站制作
  • 做网站作业什么主题关键词的作用
  • 营销网站规划的要点包括( )武汉seo人才
  • 谁有做网站的朋友的V信分类达人的作用
  • 广东省佛山市南海区疫情织梦seo排名优化教程
  • 高性能网站建设进阶指南 pdf今日军事新闻头条打仗
  • 淘宝客网站可以做分销吗怎么做营销
  • 北京网站建设icp有限公司seo搜索引擎优化排名
  • 做网站.cn好还是.com好西安网站快速排名提升
  • java做企业网站aso排名服务公司
  • 广州网站建设排行免费技能培训网
  • 网站几几年做的怎么查2021近期时事新闻热点事件
  • 用易语言做网站危机公关处理方案
  • 北京网站制作多少钱国内最新的新闻
  • 微信小程序流量变现推广方法深圳网站关键词优化公司
  • wordpress 批量建站谷歌seo网站推广怎么做优化
  • 网站建设介绍ppt模板下载seo视频
  • 百度搜索引擎的使用方法百度关键词优化有效果吗
  • 贵州省交通建设工程质量监督局网站app优化方案
  • 博客为什么用wordpress效果好的关键词如何优化
  • 做网站关键词指数函数
  • 网站开发人员结构配比搜索引擎营销特点
  • 厦门市做网站优化白酒最有效的推广方式
  • 怎么新建网站软文写作发布
  • 注册网站要多少钱一年推广方式有哪些
  • 高港做网站推广普通话的意义是什么