我怎样才能让我的设备振动? [英] How can I make my device vibrate?

查看:145
本文介绍了我怎样才能让我的设备振动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个游戏在Flash为Android与AS3。我希望用户知道他$ P $通过使设备振动短短的一秒钟pssed按钮。可有人向我解释,我怎么能做到这一点?我需要导入特定类,哪些应该在code样子?

I'm making a game in Flash for Android with AS3. I want the user to know that he pressed a button by making the device vibrate for a brief second. Can someone explain to me how I can make this happen? Do I need to import a specific class and what should the code look like?

在此先感谢!

推荐答案

感谢您的答案。他们让我进一步研究了一下这个课题。我发现是这样的:

Thanks for the answers. They made me research a bit further into this subject. What I found was this:

在你可以使用:

var vibe:Vibration;
if(Vibration.isSupported){
     vibe = new Vibration();
     vibe.vibrate(500);
}

您必须去编辑ActionScript设置>Libary路径>浏览到SWC文件

You have to go to "Edit ActionScript Settings" > "Libary Path" > "Browse to SWC file"

在那里,你必须把这些2文件:

There you have to put these 2 file in:

VibrationActionScriptLibary.swc - 你可以用得到这 zip文件

VibrationActionScriptLibary.swc - You can get with this zip file

com.adobe.extensions.Vibration.swc - 在同一个zip文件和目录。你必须改变.ane到名为.swc

com.adobe.extensions.Vibration.swc - In the same zip file and directory. You have to change the .ane to .swc

接下来,您必须进口com.adobe.nativeExtensions.Vibration; 只是把该行与其他进口

Next you have to import com.adobe.nativeExtensions.Vibration; Just put that line with the other imports.

这是所有你需要做的闪光灯。 (除了编码实际游戏...)

This was all you have to do in Flash. (Besides coding the actual game...)

接下来,打开对myApp-app.xml中。 在XML中,滚动和检查链接ns.adobe.com 3.0(或更高版本)结束。如果不是,将其更改为3.0。 Adobe AIR的3.0或更高的原生扩展。

Next up, open the myApp-app.xml. In the xml, scroll-up and check if the link to ns.adobe.com ends with 3.0 (or higher). If not, change it to 3.0. Adobe AIR 3.0 or higher is required for native extensions.

滚动进一步跌到哪里看到的部分< initialWindow> 。关闭标签后添加:

Scroll further down to the part where you see <initialWindow>. After the closing tag you add :

<extensions>
    <extensionID>com.adobe.Vibration</extensionID>
</extensions>

如果您滚动再往下,你应该看到类似&LT;机器人&GT; 。在manifestAdditions必须添加权限的设备,使之真正允许它可以使用振动功能。

If you scroll further down you should see something like <android>. In the manifestAdditions you have to add a permission for the device to make it actually allow that it can use the vibrate function.

如果现在还没有一个&LT;![CDATA [清单&GT; 也行,你必须添加它。如果你将它添加/或者如果它已经存在,你必须在允许添加。 NAME =android.permission.VIBRATE最后,你要确保它看起来是这样的:这是用机器人完成

If there is not yet a <![CDATA[manifest> line there, you have to add it. If you added it/or if it's already there you have to add in the permission. This is done with android:name="android.permission.VIBRATE" In the end you want to make sure it looks something like this:

<![CDATA[<manifest>
    <uses-permission android:name="android.permission.VIBRATE"/>
</manifest>]]>

在此,您可以保存并关闭XML文件。

After this you can save and close the xml file.

在做这一切你的根可能无法公布在Flash,因为Flash不支持我们刚刚调整了的东西。但是,我们仍然可以发布与CMD(适用于Windows)的.fla文件。这也是我对Mac用户的支持结束,伤心地。在CMD浏览到您的项目文件夹。我的项目文件夹是我的桌面上,所以我键入 CD桌面 CD游戏 CD倾斜的android游戏。当我浏览到我的文件夹我键入此命令行...

After you have done all this your .fla may fail to publish in Flash since Flash doesn't support the stuff we have just adjusted. However, we can still publish the .fla with CMD (for Windows). This is also where my support for Mac users end, sadly. In cmd you browse to your project folder. My project folder is on my desktop, so I typed cd desktop, cd games, cd tilt android game. After I browsed to my folder I typed this command line...

AdobeAIRSDK\bin\adt -package -target apk -storetyp pkcs12 -keystore YOUR_LICENCE.p12 myApp.apk myapp-app.xml myapp.swf -extdir extensionDir

请确保你在你的项目文件夹中的文件夹AdobeAIRSDK。如果以上(含CMD)是一个比较含糊去 < /一>,看他的视频和他的视频有关如何使用您的操作系统的命令行编译ANE应用程序。 (这就是我在第一时间做了。)

Make sure you have the AdobeAIRSDK folder in your project folder. If all the above (with cmd) is a bit vague go here and watch his video and his video about how to compile an ANE app with the command line for your OS. (That's what I did in the first place.)

如果您有和图标为您的应用程序,确保它们是在项目文件夹命名为图标文件夹中。如果你的图标是在这样的文件夹中只贴上的文件夹名称,在该命令行的末尾。

If you have and icon for your app, make sure they are in a folder named "icons" in your project folder. If your icons are in such a folder just paste the folder name at the end of the command line.

应用程序应在公布的项目文件夹。

The app should publish in your projects folder.

如果您对此有任何疑问,请确保你看我联系了视频。

If you have any questions about this, make sure you watch the video I linked.

这篇关于我怎样才能让我的设备振动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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