Skip to content

Instantly share code, notes, and snippets.

View alexlau811's full-sized avatar

Alex Lau alexlau811

View GitHub Profile
@alexlau811
alexlau811 / gamedev1.js
Created April 21, 2015 18:54
Code Avengers Sample Code
// Help message
new Game.Text('Warrior! Grab all', 50, 0);
new Game.Text('Hong Kong 1 Dollar to save the world!!', 50, 25);
// Setup player & guns
function createPlayer1() {
var player = new Game.Player(0, 0, '/image/game/player1.png');
player.onKilled = createPlayer1;
@alexlau811
alexlau811 / OverrideFormattedStringExtension.cs
Created March 8, 2015 10:53
Override default FormattedString behaviour to allow custom font to be used in Label of Xamarin.Forms.Android
public static class OverrideFormattedStringExtension
{
//
// Static Methods
//
public static SpannableString ToAttributed(this FormattedString formattedString, Font defaultFont, Color defaultForegroundColor, TextView view)
{
if (formattedString == null)
{
return null;
@alexlau811
alexlau811 / AnimationNavigationRenderer.cs
Created February 25, 2015 14:51
A custom renderer to set custom animation for NavigationPage.PushAsync and NavigationPage.PopAsync on iOS with Xamarin Forms.
[assembly: ExportRenderer(typeof(NavigationPage), typeof(AnimationNavigationRenderer))]
class AnimationNavigationRenderer : NavigationRenderer
{
public override void PushViewController(UIViewController viewController, bool animated)
{
if (animated)
{
// Alternative way with different set of trannsition
/*
@alexlau811
alexlau811 / ExtendedPageRenderer.cs
Created February 22, 2015 04:44
Move toolbar items with priority = 0 to LeftBarButtonItems on iOS with Xamarin Forms. Originally written by Murally at http://forums.xamarin.com/discussion/21004/navigation-bar-left-toolbar-button
[assembly: ExportRenderer(typeof(ContentPage), typeof(ExtendedPageRenderer))]
public class ExtendedPageRenderer : PageRenderer
{
public override void ViewWillAppear(bool animated)
{
base.ViewWillAppear(animated);
var contentPage = this.Element as ContentPage;
if (contentPage == null || NavigationController == null)