How to make the Android Mobile vibrate in cocos 3.0

How to make the Android Mobile vibrate in cocos 3.0
0.0 0

#1

Hello everyone,
I want to make a game that run in Android.
Now I could create a touch listener, but I want to make the mobile vibrate when I touch it.
Is there any API to complete that?I’ve searched many times,but I couldn’t solve it.
Most of them complete it by using JNI, but I face many problem when I try to imitate them.
Maybe it’s due to the difference between 2.x and 3.0.
I would appreciate it very much if anyone who complete it in the newest version could share his method,


#2

There is not API for it now.


#3

@zhangxm Will you please explain how to do vibrate functionality in ios and android both while using cocos2d-x 3.2 . I really don’t get any help on this .


#4

@shaqir29
I think it is nothing about using cocos2d-x or not.
What’s your real question?
Don’t know how to use iOS and Android vibrate API or don’t know how to invoke obj-c/java code in c++ or else?

If it is about the vibrate API, i am not familiar with it too.


#5

I have working implementation of vibrate on iOS and Android on FenneX: https://github.com/FenneX/FenneX

The header file is in Classes/FenneX/NativeWrappers/NativeUtility.h.
iOS implementation is in proj.ios_mac/ios/Misc/NativeUtility.mm
Android implemention have the C++ in proj.android/jni/NativeUtility.cpp and the Java somewhere in the src.


#6

i jus don’t know how to invoke obj-c/java code in c++


#7

I made a blog post about an easy way to do it. Thanks Fradow.