IEnumerator ButtonHoverExit(ButtonPad buttonInstance) { //for node size float vel = 0f; //for node movement float moveVel = 0.0f; float moveSpeed = 4.0f; float current = 0f; float target = .25f * buttonInstance.textStyle.textSize; while (current < target - .01f) { Color color = buttonInstance.GetComponent <MeshRenderer>().material.color; color.a = Mathf.SmoothDamp(color.a, .17f, ref vel, .02f); buttonInstance.GetComponent <MeshRenderer>().material.color = color; current = Mathf.SmoothDamp(current, target, ref moveVel, moveSpeed * Time.deltaTime); buttonInstance.node.transform.Translate(0f, 0f, -current); yield return(null); } }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as setup in the emulator/hardware new ButtonPad(this, Button.Left , Meridian.Pins.GPIO6), new ButtonPad(this, Button.Right , Meridian.Pins.GPIO8), new ButtonPad(this, Button.Up , Meridian.Pins.GPIO5), new ButtonPad(this, Button.Select, Meridian.Pins.GPIO7), new ButtonPad(this, Button.Down , Meridian.Pins.GPIO9), }; this.buttons = buttons; }
// This class maps GPIOs to Buttons processable by nanoFramework.UI.Presentation public GpioButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; GpioPin pinLeft = Gpio.OpenPin(1); GpioPin pinRight = Gpio.OpenPin(2); GpioPin pinUp = Gpio.OpenPin(3); GpioPin pinSelect = Gpio.OpenPin(4); GpioPin pinDown = Gpio.OpenPin(5); // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT, pinLeft), new ButtonPad(this, Button.VK_RIGHT, pinRight), new ButtonPad(this, Button.VK_UP, pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN, pinDown), }; this.buttons = buttons; }
IEnumerator ButtonHover(ButtonPad buttonInstance) { //for node size float vel = 0.0f; //for node movement float moveVel = 0.0f; float moveSpeed = 4.0f; float current = 0f; float target = .25f * buttonInstance.textStyle.textSize; Vector3 newPos; //changes color and moves button vector3.forward on "mouseover" (uses SmoothDamp) while (current < target - .01f) { Color color = buttonInstance.GetComponent <MeshRenderer>().material.color; color.a = Mathf.SmoothDamp(color.a, .55f, ref vel, .02f); buttonInstance.GetComponent <MeshRenderer>().material.color = color; current = Mathf.SmoothDamp(current, target, ref moveVel, moveSpeed * Time.deltaTime); buttonInstance.node.transform.Translate(0f, 0f, current); yield return(null); } }
public void ChangeMessage(TextNode node) { if (node.GetComponentsInChildren <GameTextCharacter>().Length > 0) { GameTextCharacter[] previousCharacters = node.GetComponentsInChildren <GameTextCharacter>(); for (int i = 0; i < previousCharacters.Length; i++) { Destroy(previousCharacters[i].gameObject); } ButtonPad previousPad = node.GetComponentInChildren <ButtonPad>(); if (previousPad != null) { Destroy(previousPad.gameObject); } } char[] messageArray = node.Message.ToCharArray(); Vector3[] characterLocalPositions = GetCharacterPositions(node.transform, node.TextSize, messageArray); GameTextCharacter[] prefabArray = new GameTextCharacter[messageArray.Length]; for (int i = 0; i < messageArray.Length; i++) { GameTextCharacter instance = Instantiate(characters[messageArray[i]], node.transform); instance.transform.localPosition = characterLocalPositions[i]; instance.transform.Rotate(0, 90, 90); prefabArray[i] = instance; } node.PrefabArray = prefabArray; }
/// <summary> /// Maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation. /// </summary> /// <param name="source"></param> public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register the object as an input source with the input manager and // get back an InputProviderSite object. The InputProviderSite // object forwards the input report to the input manager. The input // manager then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's // ReportInput method. callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return site.ReportInput(args.Device, args.Report); }); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider. HardwareProvider hwProvider = new HardwareProvider(); // Create the pins that are needed for the buttons. Default their // values for the emulator. Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins. If the left pin is // not set, assume none of the pins are set and set the left pin // back to the default emulator value. if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) pinLeft = Cpu.Pin.GPIO_Pin0; else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as // input from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons with the pins as discovered or set // above. new ButtonPad(this, Button.VK_LEFT , pinLeft ), new ButtonPad(this, Button.VK_RIGHT , pinRight ), new ButtonPad(this, Button.VK_UP , pinUp ), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN , pinDown ), }; this.buttons = buttons; }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as setup in the emulator/hardware new ButtonPad(this, Button.VK_LEFT, (Cpu.Pin) 86), new ButtonPad(this, Button.VK_RIGHT, (Cpu.Pin) 87), new ButtonPad(this, Button.VK_UP, (Cpu.Pin) 88), new ButtonPad(this, Button.VK_SELECT, (Cpu.Pin) 89), new ButtonPad(this, Button.VK_DOWN, (Cpu.Pin) 90), // For a hardware board that has predefined buttons, can use the // Microsoft.SPOT.Hardware.GetButtonPin to retrieve the GPIO pin number associate // with button name // new ButtonPad(this, Button.Left , hwProvider.GetButtonPins(Button.Left)), // new ButtonPad(this, Button.Right , hwProvider.GetButtonPins(Button.Right)), // new ButtonPad(this, Button.Up , hwProvider.GetButtonPins(Button.Up)), // new ButtonPad(this, Button.Select, hwProvider.GetButtonPins(Button.Select)), // new ButtonPad(this, Button.Down , hwProvider.GetButtonPins(Button.Down)), }; this.buttons = buttons; }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as setup in the emulator/hardware new ButtonPad(this, Button.Left, Meridian.Pins.GPIO6), new ButtonPad(this, Button.Right, Meridian.Pins.GPIO8), new ButtonPad(this, Button.Up, Meridian.Pins.GPIO5), new ButtonPad(this, Button.Select, Meridian.Pins.GPIO7), new ButtonPad(this, Button.Down, Meridian.Pins.GPIO9), }; this.buttons = buttons; }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider HardwareProvider hwProvider = new HardwareProvider(); // Create the pins we will need for the buttons // Default their values for the emulator Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins // If the left pin is not set then assume none of them are // and set the left pin back to the default emulator value if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) { pinLeft = Cpu.Pin.GPIO_Pin0; } else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT, pinLeft), new ButtonPad(this, Button.VK_RIGHT, pinRight), new ButtonPad(this, Button.VK_UP, pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN, pinDown), }; this.buttons = buttons; }
/// <summary> /// Maps GPIOs to Buttons that can be processed by /// Microsoft.SPOT.Presentation. /// </summary> /// <param name="source"></param> public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and // get back an InputProviderSite object which forwards the input // report to the input manager, which then places the input in the // staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's // ReportInput method. callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return(site.ReportInput(args.Device, args.Report)); }); Dispatcher = Dispatcher.CurrentDispatcher; //-------------- // Create a hardware provider. // HardwareProvider hwProvider = new HardwareProvider(); //-------------- // Create the pins that are needed for the buttons. Default their // values for the emulator. GpioPin pinLeft = Gpio.OpenPin(1); GpioPin pinRight = Gpio.OpenPin(2); GpioPin pinUp = Gpio.OpenPin(3); GpioPin pinSelect = Gpio.OpenPin(4); GpioPin pinDown = Gpio.OpenPin(5); // Allocate button pads and assign the (emulated) hardware pins as // input from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT, pinLeft), new ButtonPad(this, Button.VK_RIGHT, pinRight), new ButtonPad(this, Button.VK_UP, pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN, pinDown), }; this.buttons = buttons; }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider HardwareProvider hwProvider = new HardwareProvider(); // Create the pins we will need for the buttons // Default their values for the emulator Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins // If the left pin is not set then assume none of them are // and set the left pin back to the default emulator value if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) pinLeft = Cpu.Pin.GPIO_Pin0; else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT , pinLeft), new ButtonPad(this, Button.VK_RIGHT , pinRight), new ButtonPad(this, Button.VK_UP , pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN , pinDown), }; this.buttons = buttons; }
IEnumerator TextButtonClick(ButtonPad buttonInstance) { float speed = 2.0f; float targetScale = .09f; float vel = 0f; while (buttonInstance.transform.parent.transform.localScale.x > .1) { Vector3 newScale = buttonInstance.transform.parent.transform.localScale; newScale.x = Mathf.SmoothDamp(newScale.x, targetScale, ref vel, speed * Time.deltaTime); newScale.y = Mathf.SmoothDamp(newScale.y, targetScale, ref vel, speed * Time.deltaTime); buttonInstance.transform.parent.transform.localScale = newScale; yield return(null); } //stopping all coroutines to prevent errors in case hover or exit animation still running (for now) StopAllCoroutines(); buttonInstance.trigger(); }
public GPIOButtonInputProvider(PresentationSource source) { _source = source; _site = InputManager.CurrentInputManager.RegisterInputProvider(this); _callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return(_site.ReportInput(args.Device, args.Report)); }); Dispatcher = Dispatcher.CurrentDispatcher; ButtonPad[] buttons = new ButtonPad[] { new ButtonPad(this, Button.VK_MENU, Pins.GPIO_PORT_A_3, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_SELECT, Pins.GPIO_PORT_A_8, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_LEFT, Pins.GPIO_PORT_A_7, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_RIGHT, Pins.GPIO_PORT_A_5, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_UP, Pins.GPIO_PORT_A_4, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_DOWN, Pins.GPIO_PORT_A_6, Port.InterruptMode.InterruptEdgeBoth), }; _buttons = buttons; }
public GPIOButtonInputProvider(PresentationSource source) { _source = source; _site = InputManager.CurrentInputManager.RegisterInputProvider(this); _callback = new DispatcherOperationCallback(delegate(object report) { InputReportArgs args = (InputReportArgs)report; return _site.ReportInput(args.Device, args.Report); }); Dispatcher = Dispatcher.CurrentDispatcher; ButtonPad[] buttons = new ButtonPad[] { new ButtonPad(this, Button.VK_MENU, Pins.GPIO_PORT_A_3, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_SELECT, Pins.GPIO_PORT_A_8, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_LEFT, Pins.GPIO_PORT_A_7, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_RIGHT, Pins.GPIO_PORT_A_5, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_UP, Pins.GPIO_PORT_A_4, Port.InterruptMode.InterruptEdgeBoth), new ButtonPad(this, Button.VK_DOWN, Pins.GPIO_PORT_A_6, Port.InterruptMode.InterruptEdgeBoth), }; _buttons = buttons; }
// This class maps GPIOs to Buttons processable by Microsoft.SPOT.Presentation public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and get back an // InputProviderSite object which forwards the input report to the input manager, // which then places the input in the staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's ReportInput method callback = new ReportInputCallback(site.ReportInput); Dispatcher = Dispatcher.CurrentDispatcher; // Allocate button pads and assign the (emulated) hardware pins as input // from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as setup in the emulator/hardware new ButtonPad(this, Button.VK_LEFT , (Cpu.Pin)86), new ButtonPad(this, Button.VK_RIGHT , (Cpu.Pin)87), new ButtonPad(this, Button.VK_UP , (Cpu.Pin)88), new ButtonPad(this, Button.VK_SELECT, (Cpu.Pin)89), new ButtonPad(this, Button.VK_DOWN , (Cpu.Pin)90), // For a hardware board that has predefined buttons, can use the // Microsoft.SPOT.Hardware.GetButtonPin to retrieve the GPIO pin number associate // with button name // new ButtonPad(this, Button.Left , hwProvider.GetButtonPins(Button.Left)), // new ButtonPad(this, Button.Right , hwProvider.GetButtonPins(Button.Right)), // new ButtonPad(this, Button.Up , hwProvider.GetButtonPins(Button.Up)), // new ButtonPad(this, Button.Select, hwProvider.GetButtonPins(Button.Select)), // new ButtonPad(this, Button.Down , hwProvider.GetButtonPins(Button.Down)), }; this.buttons = buttons; }
/// <summary> /// Maps GPIOs to Buttons that can be processed by /// Microsoft.SPOT.Presentation. /// </summary> /// <param name="source"></param> public GPIOButtonInputProvider(PresentationSource source) { // Set the input source. this.source = source; // Register our object as an input source with the input manager and // get back an InputProviderSite object which forwards the input // report to the input manager, which then places the input in the // staging area. site = InputManager.CurrentInputManager.RegisterInputProvider(this); // Create a delegate that refers to the InputProviderSite object's // ReportInput method. callback = new DispatcherOperationCallback(delegate(object report) { #if MF_FRAMEWORK_VERSION_V3_0 return(site.ReportInput((InputReport)report)); #else InputReportArgs args = (InputReportArgs)report; return(site.ReportInput(args.Device, args.Report)); #endif }); Dispatcher = Dispatcher.CurrentDispatcher; // Create a hardware provider. HardwareProvider hwProvider = new HardwareProvider(); // Create the pins that are needed for the buttons. Default their // values for the emulator. Cpu.Pin pinLeft = Cpu.Pin.GPIO_Pin0; Cpu.Pin pinRight = Cpu.Pin.GPIO_Pin1; Cpu.Pin pinUp = Cpu.Pin.GPIO_Pin2; Cpu.Pin pinSelect = Cpu.Pin.GPIO_Pin3; Cpu.Pin pinDown = Cpu.Pin.GPIO_Pin4; // Use the hardware provider to get the pins. If the left pin is // not set, assume none of the pins are set, and set the left pin // back to the default emulator value. if ((pinLeft = hwProvider.GetButtonPins(Button.VK_LEFT)) == Cpu.Pin.GPIO_NONE) { pinLeft = Cpu.Pin.GPIO_Pin0; } else { pinRight = hwProvider.GetButtonPins(Button.VK_RIGHT); pinUp = hwProvider.GetButtonPins(Button.VK_UP); pinSelect = hwProvider.GetButtonPins(Button.VK_SELECT); pinDown = hwProvider.GetButtonPins(Button.VK_DOWN); } // Allocate button pads and assign the (emulated) hardware pins as // input from specific buttons. ButtonPad[] buttons = new ButtonPad[] { // Associate the buttons to the pins as discovered or set above new ButtonPad(this, Button.VK_LEFT, pinLeft), new ButtonPad(this, Button.VK_RIGHT, pinRight), new ButtonPad(this, Button.VK_UP, pinUp), new ButtonPad(this, Button.VK_SELECT, pinSelect), new ButtonPad(this, Button.VK_DOWN, pinDown), }; this.buttons = buttons; }
public void PointerExitButton(ButtonPad buttonInstance) { StartCoroutine(ButtonHoverExit(buttonInstance)); }
public void GameTextButtonClick(ButtonPad buttonInstance) { StartCoroutine(TextButtonClick(buttonInstance)); }