Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/redth/eggstogo
Xamarin Cross Platform mobile library for implementing Easter Eggs!
https://github.com/redth/eggstogo
Last synced: 23 days ago
JSON representation
Xamarin Cross Platform mobile library for implementing Easter Eggs!
- Host: GitHub
- URL: https://github.com/redth/eggstogo
- Owner: Redth
- License: mit
- Created: 2013-08-01T14:29:47.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-10-13T18:39:04.000Z (about 7 years ago)
- Last Synced: 2024-10-13T15:08:26.810Z (25 days ago)
- Language: C#
- Size: 839 KB
- Stars: 13
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Eggs-To-Go
==========Eggs-To-Go is a Xamarin Cross Platform mobile library for implementing Easter Egg gestures!
Features
--------
- Konami and Mortal Kombat code
- Create your own Custom sequences
- Xamarin.iOS and Xamarin.Android support
- Xamarin Component store
Getting Started - Xamarin.iOS
-----------------------------
You can use the following code with any UIView you would like to recognize eggs/codes on (for example in a View Controller). It will attach gesture listeners to the view you specify in the actor:```csharp
//Create our new instance, specifying the UIView to recognize gestures on
var easter = new EggsToGo.Easter (this.View, new KonamiCode());//Event for when a egg/code has been detected (eg: Konami Code)
easter.EggDetected += egg => Console.WriteLine("Egg: " + egg.Name);//You can see each individual command as it happens too
easter.CommandDetected += cmd => Console.WriteLine("Command: " + cmd.Value);
```
Getting Started - Xamarin.Android
---------------------------------
Android is a bit trickier than iOS, simply because recognizing gestures requires a MotionEvent of some sort. Typically you would override the OnTouchEvent in an activity and pass that along to the Easter instance. The Easter instance doesn't care where this information comes from, but it needs it in order to recognize gestures.You can use the following code in the Activity you would like to support the gesture detection:
```csharp
public class MainActivity : Activity
{
EggsToGo.Easter easter;
protected override OnCreate(Bundle bundle)
{
base.OnCreate (bundle);
SetContentView(Resource.Layout.Main);
easter = new EggsToGo.Easter (new KonamiCode());
//Event for when a egg/code has been detected (eg: Konami Code)
easter.EggDetected += egg =>
Toast.MakeText(this, egg.Name, ToastLength.Short).Show();
//You can see each individual command as it happens too
easter.CommandDetected += cmd =>
Android.Util.Log.Debug("EggsToGo", "Commadn: " + cmd.Value);
}
public override bool OnTouchEvent(MotionEvent e)
{
//IMPORTANT: You must pass this event on to the Easter class
easter.OnTouchEvent(e);
return base.OnTouchEvent(e);
}
}
```Default Egg Sequences
---------------------
By default I've included the Konami code and Mortal Kombat code:- **Konami Code:** UP, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, TAP, TAP
- **Mortal Kombat Code:** DOWN, UP, DOWN, DOWN, LEFT, RIGHT, LEFT, RIGHT, TAP, TAPCustom Egg Sequences
--------------------
By default the Konami and Mortal Kombat codes are built in, but you may want to add your own sequences!```csharp
var easyEgg = new CustomEgg("Easy")
.WatchForSequence(Command.SwipeUp(), Command.SwipeDown(), Command.Tap());
var easter = new Easter(this.View, easyEgg);
```Thanks
------
Thanks to Eight-Bot software for their original post on getting this working with Mono for Android: http://eightbot.com/writeline/developer/konami-code-detection-with-mono-for-android/This was definitely my inspiration for making this simple component!