andsveking / def_taptic_engine

Native extension for Defold with Taptic Engine implementation for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TapticEngine

This is a small native extension for Defold engine which allows to use iOS Taptic Engine.

Installation

You can use the DefTapticEngine extension in your own project by adding this project as a Defold library dependency. Open your game.project file and in the dependencies field under project add:

https://github.com/MaratGilyazov/def_taptic_engine/archive/master.zip

Example

if (taptic_engine and taptic_engine.isSupported()) then
  
  taptic_engine.impact(taptic_engine.IMPACT_LIGHT)
  taptic_engine.impact(taptic_engine.IMPACT_MEDIUM)
  taptic_engine.impact(taptic_engine.IMPACT_HEAVY)
  
  taptic_engine.notification(taptic_engine.NOTIFICATION_SUCCESS)
  taptic_engine.notification(taptic_engine.NOTIFICATION_WARNING)
  taptic_engine.notification(taptic_engine.NOTIFICATION_ERROR)
  
  taptic_engine.selection()

else
  --do something else
end

LUA Api

taptic_engine.isSupported()

Returns bool flag saying if taptic engine is supprorted

taptic_engine.impact(int style)

Call Taptic Engine Impact feedback with given style - one of 3 constants: taptic_engine.IMPACT_LIGHT, taptic_engine.IMPACT_MEDIUM, taptic_engine.IMPACT_HEAVY

taptic_engine.notification(int type)

Call Taptic Engine Notification feedback with given type - one of 3 constants: taptic_engine.NOTIFICATION_SUCCESS, taptic_engine.NOTIFICATION_WARNING, taptic_engine.NOTIFICATION_ERROR

taptic_engine.selection()

Call Taptic Engine Selection feedback

Notes

taptic_engine.isSupported()

Right now this does not seem working correctly and returns "true" even on iPhone5, but it's not breaking; there is no safe way to check if taptic is supported)

prepare()

There is API to "prepare" taptic engine for further feedback calls, in actual implementation it's called once on first call to any of taptic_engine methods and there is no way to controll it manually

iOS part is based on iOS TAPTIC Engine Bridge for Unity by Koki Ibukuro

About

Native extension for Defold with Taptic Engine implementation for iOS

License:MIT License


Languages

Language:Objective-C++ 47.2%Language:C++ 45.1%Language:C 7.7%