Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vanyasem/godot-timeelapsed
Godot Module for tracking time bound events on Android
https://github.com/vanyasem/godot-timeelapsed
android bound-events godot timer timestamp ts
Last synced: 5 days ago
JSON representation
Godot Module for tracking time bound events on Android
- Host: GitHub
- URL: https://github.com/vanyasem/godot-timeelapsed
- Owner: vanyasem
- License: mit
- Created: 2017-06-19T04:14:22.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-02-29T22:05:50.000Z (almost 5 years ago)
- Last Synced: 2024-12-17T16:47:41.815Z (about 2 months ago)
- Topics: android, bound-events, godot, timer, timestamp, ts
- Language: Java
- Size: 10.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Godot-TimeElapsed
This is an Android module for [Godot Engine](https://github.com/okamstudio/godot).This module can track time bound events on Android. I.e. Time since last start. It's not affected by local timezone or date. It doesn't work in background as a sevice.
## Installation
- Copy `elapsed` folder inside the `modules` directory of the Godot source.- You must [recompile](https://godot.readthedocs.io/en/stable/development/compiling/compiling_for_android.html) Godot for Android.
- Finally, you need to include the module in your `engine.cfg` (if you have more than one module separate them by comma):
```
[android]
modules="org/godotengine/godot/TimeElapsed"
```## How to use
It's a very dull module:```python
var old_time_secs = null
var time_elapsed = nullfunc _ready():
if Globals.has_singleton("TimeElapsed"):
time_elapsed = Globals.get_singleton("TimeElapsed")
passfunc get_difference():
if time_elapsed != null and old_time_secs != null:
return time_elapsed.getDifferenceSeconds(old_time_secs)
return -1func get_current_time_secs():
# It's useful to save that data before app quits and
# then compare it to current one when the app is started again
# i.e. you want to reset some cooldown, but want it to be timezone independent
old_time_secs = getNanoTimeInSeconds()
pass
```## API Reference
The following methods are available:```python
# Get current nanotime in seconds
getNanoTimeInSeconds()# Get current nanotime in minutes
getNanoTimeInMinutes()# Get current nanotime in hours
getNanoTimeInHours()# Get difference between previous nanotime in seconds and the current one
# @param String prevHours Previous nanotime value in seconds
getDifferenceSeconds(prevSecs)# Get difference between previous nanotime in minutes and the current one
# @param String prevHours Previous nanotime value in minutes
getDifferenceMinutes(prevMins)# Get difference between previous nanotime in hours and the current one
# @param String prevHours Previous nanotime value in hours
getDifferenceHours(prevHours)
```