如何在蛇游戏中添加背景音乐,并将Apple图像添加为蛇的食物 [英] How to add a background music in snake game and also Apple image as a food of a snake

查看:78
本文介绍了如何在蛇游戏中添加背景音乐,并将Apple图像添加为蛇的食物的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Asp.Net中使用C#制作蛇游戏。我想在游戏中添加背景声音。当用户需要时如何暂停游戏



我尝试了什么:



我在项目的调试文件夹中交换mp3声音并尝试使用<$添加p $ p> System.Media.SoundPlayer轨道=新System.Media.SoundPlayer(@ E:\Asp\Snake\Snake\bin\Debug\Snake.wav);





但它不起作用

解决方案

你'重新制作游戏......在网络服务器上运行...除非是通过浏览器或其他应用程序,否则不会真正允许用户交互。考虑一下。



ASP.NET代码完全运行在服务器端。它的一个字节不在客户端或浏览器中运行。它只能在您的机器上运行,因为当您运行代码时,您的机器既是服务器又是客户端。



上面的代码只会播放服务器上的声音,而不是客户端。



所以,你用javascript编写这个游戏吗?我当然希望如此。


我在Asp.Net桌面应用程序中制作游戏。


I make a Snake Game using C# in Asp.Net.I want to add Background Sound in the game.How can i Pause the game when the user want

What I have tried:

I am Swap the mp3 sound in the debug folder of a project and try to add by using

System.Media.SoundPlayer track = new System.Media.SoundPlayer(@"E:\Asp\Snake\Snake\bin\Debug\Snake.wav");



but its not working

解决方案

You're making a game...running on a web server...that doesn't really allow user interaction unless it's through a browser or another application. Think about that.

ASP.NET code runs ENTIRELY server-side. Not one byte of it runs on the client or in the browser. It only "works on your machine" because, when you run the code, your machine is both the server AND the client.

The code you have above will only play sounds on the server, not the client.

So, did you write this game in javascript? I sure hope so.


I'm Make a Game in Asp.Net Desktop Application.


这篇关于如何在蛇游戏中添加背景音乐,并将Apple图像添加为蛇的食物的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆