Today, I will write two commonly used plug-ins in unity3d: easytouch and ngui. The versions I used are easytouch 3.1.1 and ngui 3.6.0 respectively. The following are my learning experiences on these two versions.
1. easytouch
Easytouch is a plug-in for the touch screen. It provides a virtual touch button, which consists of three parts: a joystick, a button, and a touch response.
1.1 easytouch joystick
This
SneakyInput is a virtual joystick library. SneakyInput is the virtual handle in 2dx. But the 2dx version downloaded from the official website is too old, to modify him, applicable to cocos2d-x 2.1.4 version. In theory, it applies to all 2dx versions 2.1 +. Go to the topic: [cpp] # include "SneakyInput/SneakyJoystickSkinnedBase. h "# include" SneakyInput/SneakyButtonSkinnedBase. h "SneakyButton * button; SneakyJoystick *
Information Method *********/publicvoidbluesend (byte[]msg) { try{tmpout=bluetoothsocket.getoutputstream (); NBSP;NBSP;NBSP;NBSP;SYSTEM.OUT.PRINTLN ("Generate output stream"); NBSP;NBSP;NBSP;NBSP;LOG.D ("Send", arrays.tostring (msg)) NBSP;NBSP;NBSP;NBSP;SYSTEM.OUT.PRINTLN ("The output stream is being sent to the buffer"); tmpout.write (msg); NBSP;NBSP;NBSP;SYSTEM.OUT.PRINTLN ("Successful output stream to buffer"); }catch (ioexceptione) { Nbsp;e.printstacktrace (); System.out.println ("Unable to
First create an instance of a stickI'm here to change the name to moveCopy the name Rotate.Tick the dynamic display so that the user clicks on the joystick (now the joystick game is displayed dynamically)Set the position of the joystick (one in the lower left and one in the lower Right)Click on the bottom left of the screenThe character moves directly with the
linear.x.
Maybe you've seen the type of/joy topic.
Rostopic Type/joyShow
Sensor_msgs/joy
$rosmsg Show Sensor_msgs/joy
Std_msgs/header Header
uint32 seq Time
stamp
string frame_id
float32[] axes
int32[] Buttons
OK, now I also know the topic of/joy and its type. Let's start writing code:
#include
After that, run this node, turtle node, handle node, you can control the turtle. Now we program these three nodes to launch files and set the control buttons and speed:
When you start the
Code introduction:When the timing in the developed game is about to end, in order to create a tense atmosphere, the heartbeat effect will be simulated by the vibration of the mobile phone itself. In fact, this heartbeat effect is really simple. So you can directly run the code (note that the simulator cannot simulate the vibration, so you have to test it on a real machine)
Package com. Ray. test;
Import Android. App. activity;
Import Android. OS. Bundle;
Import Android.
In the Windows environment by programming to manipulate the mouse, keyboard is a simple thing, but have you ever thought to try another one of our more common input tools-game joystick? In some cases, especially in the form of small game software, the addition of support to the joystick can provide users with a more user-friendly man-machine interface, greatly improve the game software to play.
There is no
-generated method stub if (camera! = Null) {camera. stopPreview (); // release the camera resource camera. release (); camera = null;} private void releaseCamera () {// TODO Auto-generated method stubif (camera! = Null) {camera. stopPreview (); // release the camera resource camera. release (); camera = null;} 4. Callback Method for configuring Camera sound or vibration [html] camera. shutterCallback shutter = new ShutterCallback () {@ Override public void onShutter () {// TODO Auto-generated me
To achieve the "shake" function, in fact very simple, is to detect the gravity sensor mobile phone, the implementation of the Code as follows:
1, add the Operation permission in the Androidmanifest.xml
2, implementation code
Package com.xs.test;
Import android.app.Activity;
Import Android.hardware.Sensor;
Import android.hardware.SensorEvent;
Import Android.hardware.SensorEventListener;
Import Android.hardware.SensorManager;
Import Android.os.Bundle;
Import Android.os.Handler;
Imp
. getMaximumRange (): maximum value range.2. getName (): Device Name3. getPower (): Power4. getResolution (): Precision5. getType (): Sensor Type6. getVendor (): Device supplier7. getVersion (): device version
The SensorEvent class is used to describe sensor events and encapsulate information about sensor events. The information includes sensor type, time, accuracy, and sensor raw data.
SensorEventListener: used to listen to a sensor. When the sensor's precision or data changes, the correspondi
directly inject the current//context since the Nge depending on what//are using Astroboy//at the time.
Instead we use the application context.
Vibrator is bound to Context.getsystemservice (Vibrator_service) in//Defaultrobomodule.
Random has no special bindings, so Guice'll create a new instance for//us.
@Inject application Application;
@Inject Vibrator
Friends is going to play console. They has joysticks and only one charger for them. Initially first joystick is charged at a1 percent and second one was charged at a2 Percen T. You can connect charger to a joystick only on the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent
A. joystickstime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputFriends is going to play console. They has joysticks and only one charger for them. Initially first joystick is charged at a1 Percent and second one is charged at a2 Percent. You can connect charger to a joystick only at the beginning for each minute. In one minute
This paper illustrates the method of Android to realize the vibration setting of mobile phone. Share to everyone for your reference. Specifically as follows:
Main.xml Layout file:
Manifest file:
Vibrateactivity class:
Package com.ljq.activity;
Import android.app.Activity;
Import Android.app.Service;
Import Android.os.Bundle;
Import Android.os.Vibrator;
Import Android.widget.CompoundButton;
Import Android.widget.TextView;
Import Android.widget.ToggleButton;
Import And
Previously, we used surfaceview to draw a joystick disc in the project and set surfaceview transparency. However, this would cause surfaceview components to overwrite other components, which is generally irrelevant, in other cases, the pull-up and drop-down functions are similar. The layout to be pulled is located at the top to overwrite other components. The following figure shows the transparent usage of surfaceview:
Setzorderontop (true); mholder.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.