I am using unity3D engine to create a game involving cars - android

while doing the controls I have encountered the following errors.
Assets/Car/Scripts/NewBehaviourScript.js(78,22): UCE0001: ';' expected. Insert a semicolon at the end.
Assets/Car/Scripts/NewBehaviourScript.js(78,10): BCE0044: expecting (, found 'ShiftGears'.
Assets/Car/Scripts/NewBehaviourScript.js(79,9): BCE0043: Unexpected token: if.
Assets/Car/Scripts/NewBehaviourScript.js(79,41): UCE0001: ';' expected. Insert a semicolon at the end.
these errors does'nt usually appear in sxripting in unity and this is the first time that I have encountered it.
here is my code
#pragma strict
var FrontLeftWheel : WheelCollider;
var FrontRightWheel : WheelCollider;
var BackLeftWheel : WheelCollider;
var BackRightWheel : WheelCollider;
var gasButton : GUITexture;
var breakButton : GUITexture;
var leftTurnButton : GUITexture;
var rightTurnButton : GUITexture;
var motorInputTouch : int = 0;
var breakPower : float = 200;
var GearRatio : float[];
var CurrentGear : int = 0;
var EngineTorque : float = 230.0;
var MaxEngineRPM : float = 3000.0;
var MinEngineRPM : float = 1000.0;
private var EngineRPM : float = 0.0;
function Awake() {
gasButton = GameObject.Find("Gas_Pedal").guiTexture;
breakButton = GameObject.Find("brake_Pedal").guiTexture;
leftTurnButton = GameObject.Find("Left_Turn_Button").guiTexture;
rightTurnButton = GameObject.Find("Right_Turn_Button").guiTexture;
}
function start() {
rigidbody.centerOfMass += Vector3(0, -1, .25);
}
function update() {
for (var touch : Touch in Input.touches)
{
if (touch.phase == TouchPhase.Stationary && gasButton.HitTest (touch.position)){
motorInputTouch = 1;
}
else if (touch.phase == TouchPhase.Ended && gasButton.HitTest){
motorInputTouch = 0;
}
if (touch.phase == TouchPhase.Stationary && breakButton.HitTest (touch.position)){
breakPower = 200;
}
else if (touch.phase == TouchPhase.Ended && breakButton.HitTest){
breakPower = 0;
}
if (touch.phase == TouchPhase.Stationary && leftTurnButton.HitTest (touch.position)){
FrontLeftWheel.steerAngle = -15;
FrontRightWheel.steerAngle = -15;
}
else if (touch.phase == TouchPhase.Ended && leftTurnButton.HitTest){
FrontLeftWheel.steerAngle = 0;
FrontRightWheel.steerAngle = 0;
}
if (touch.phase == TouchPhase.Stationary && rightTurnButton.HitTest (touch.position)){
FrontLeftWheel.steerAngle = 15;
FrontRightWheel.steerAngle = 15;
}
else if (touch.phase == TouchPhase.Ended && rightTurnButton.HitTest){
FrontLeftWheel.steerAngle = 0;
FrontRightWheel.steerAngle = 0;
}
EngineRPM = (FrontLeftWheel.rpm + FrontRightWheel.rpm)/2 * GearRatio[CurrentGear];
ShiftGears();
audio.pitch = Mathf.Aba(EngineRPM / MaxEngine + 1.0);
if (audio.pitch > 2.0) {
audio.pitch = 2.0;
}
FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * motorInputTouch;
FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * motorInputTouch;
//FrontLeftWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
//FrontRightWheel.steerAngle = 10 * Input.GetAxis("Horizontal");
}
function ShiftGears() {
if ( EngineRPM >= MaxEngineRPM ) {
var AppropriateGear : int = CurrentGear;
for ( var i = 0; i < GearRatio.length; i++) {
if (FrontLeftWheel.rpm * GearRatio[i] < MaxEngineRPM ) {
AppropriateGear = i;
break;
}
}
CurrentGear = AppropriateGear;
}
if (EngineRPM <= MinEngineRPM ) {
AppropriateGear = CurrentGear;
for (var j = GearRatio.Length-1; j >= 0; j--) {
if ( FrontLeftWheel.rpm * GearRatio[j] > MinEngineRPM ) {
AppropriateGear = j;
break;
}
}
CurrentGear = AppropriateGear;
}
}
any one here who can help me debug this? thanks a lot.

You are missing a closing bracket }. Either to end your for loop inside the Update(), or to signify the end of your Update() function. That causes the rest of the errors you're seeing.

Related

Multi-Swipe in Unity

So I am trying to make a simple android game in which player has to move two objects in different halfs of the screen at the same time using swipes. It works just fine if I try to swipe to move one object and then the second one a moment after the first. But if I try swiping in two halfs at the same time it won't work. I tried managing with so-called multi-tuch but... well I need extra help.
public static event OnSwipeInput SwipeEvent;
public delegate void OnSwipeInput(Vector2 direction,bool side);
public static event OnSwipeInput SwipeEvent2;
private Vector2 tapPosition;
private Vector2 tapPosition2;
private Vector2 delta;
private Vector2 delta2;
private float deadZone = 30;
private bool isSwiping;
private bool isSwiping2;
private bool isMobile;
private bool left_side = true;
private bool left_side2 = true;
void Start()
{
isMobile = Application.isMobilePlatform;
isMobile = true;
Debug.Log("aaaa "+isMobile);
}
void Update()
{
float p;
if (!isMobile)
{
p = Mathf.Abs(Input.mousePosition.x) - Screen.width / 2;
if (Input.GetMouseButtonDown(0))
{
isSwiping = true;
tapPosition = Input.mousePosition;
if (p < 0)
left_side = true;
else
left_side = false;
}
else if(Input.GetMouseButtonDown(0))
ResetSwipe();
}
else
{
if (Input.touchCount >= 1) //try
{
if (Input.GetTouch(0).phase == TouchPhase.Began)
{
p = Mathf.Abs(Input.GetTouch(0).position.x) - Screen.width / 2;
if (p < 0)
left_side = true;
else
left_side = false;
isSwiping = true;
tapPosition = Input.GetTouch(0).position;
}
else if (Input.GetTouch(0).phase == TouchPhase.Canceled || Input.GetTouch(0).phase == TouchPhase.Ended)
{
ResetSwipe();
}
}
if (Input.touchCount >= 2)
{
Input.multiTouchEnabled = true;
if (Input.GetTouch(1).phase == TouchPhase.Began)
{
p = Mathf.Abs(Input.GetTouch(1).position.x) - Screen.width / 2;
if (p < 0)
left_side2 = true;
else
left_side2 = false;
isSwiping2 = true;
tapPosition2 = Input.GetTouch(1).position;
}
else if (Input.GetTouch(1).phase == TouchPhase.Canceled || Input.GetTouch(1).phase == TouchPhase.Ended)
{
ResetSwipe2();
}
}
}
CheckSwipe();
}
private void CheckSwipe(){
if(Input.touchCount >= 1 || Input.GetMouseButton(0))
{
Debug.Log("there is 1 swipe");
delta = Vector2.zero;
if (isSwiping)
{
if (!isMobile && Input.GetMouseButton(0))
{
delta = (Vector2)Input.mousePosition - tapPosition;
}
else if (Input.touchCount == 1)
{
delta = (Vector2)Input.GetTouch(0).position - tapPosition;
}
}
if (delta.magnitude > deadZone)
{
if (SwipeEvent != null)
{
if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
{
SwipeEvent.Invoke(delta.x > 0 ? Vector2.right : Vector2.left, left_side);
}
else
{
SwipeEvent.Invoke(delta.y > 0 ? Vector2.up : Vector2.down, left_side);
}
}
ResetSwipe();
}
}
else
{
Debug.Log("there are NO swipes");
}
if (Input.touchCount == 2)
{
Debug.Log("there are 2 swipes");
delta2 = Vector2.zero;
if (isSwiping2)
{
if (Input.touchCount == 2)
{
delta2 = (Vector2)Input.GetTouch(1).position - tapPosition;
}
}
if (delta2.magnitude > deadZone)
{
if (SwipeEvent2 != null)
{
if (Mathf.Abs(delta.x) > Mathf.Abs(delta.y))
{
SwipeEvent2.Invoke(delta2.x > 0 ? Vector2.right : Vector2.left, left_side2);
}
else
{
SwipeEvent2.Invoke(delta2.y > 0 ? Vector2.up : Vector2.down, left_side2);
}
}
ResetSwipe2();
}
}
}
private void ResetSwipe()
{
isSwiping=false;
tapPosition=Vector2.zero;
delta = Vector2.zero;
}
private void ResetSwipe2()
{
isSwiping2 = false;
tapPosition2 = Vector2.zero;
delta2 = Vector2.zero;
}
As you can see I am trying to operate with swipes differently seeing how many touches there are. No luck so far.
Any advice will be appriciated!
thank you

How can the motion of the rocket be optimized?

I am making a missile interception strategy game, why does it give an error message when trying to removing enemy birds?
How can the motion of the rocket be optimized ?
Why aren't the enemies eliminated?
Here is my Build Rocket code...
stage.addEventListener(MouseEvent.CLICK, letsgoeasy)
function letsgoeasy(e: MouseEvent): void {
var Rocket: Hawk = new Hawk();
Rocket.x = p.x;
Rocket.y = p.y;
Rocket.scaleX = 0.2;
Rocket.scaleY = 0.2;
addChild(Rocket);
Rocket.addEventListener(Event.ENTER_FRAME, moveBullet);
function moveBullet(e: Event) {
}
var myTimer: Timer = new Timer(2000);
var speedF: Number = 5;
var RocketBox: Array = new Array;
Rocket.addEventListener(Event.ENTER_FRAME, follow);
function follow(e: Event): void {
myTimer.start();
if (enemyFleet[h].y > 100) {
for (var h: int = 0; h < enemyFleet.length; h++) {
Rocket.x -= (Rocket.x - enemyFleet[h].x) / speedF;
Rocket.x = Rocket.x + 2;
Rocket.y -= (Rocket.y - enemyFleet[h].y) / speedF;
Rocket.y = Rocket.y + 3;
RocketBox.push(Rocket)
}
}
//Fire Rocket part
var smoke: smoke_shell = new smoke_shell();
addChild(smoke);
smoke.scaleX = 0.1;
smoke.scaleY = 0.1;
smoke.x = Rocket.x
smoke.y = Rocket.y + 10
smoke.rotation = 0
smoke.color = 0xE77471;
smoke.blurX = 3;
smoke.blurY = 3;
smoke.strength = 100;
smoke.quality = 3;
removeChild(null);
}
// collision part
addEventListener(Event.ENTER_FRAME, collCkeck);
function collCkeck(e: Event): void {
for (var s: int = Rocket.length - 1; s >= 0; s--) {
if (Rocket.hitTestObject(enemyFleet[s])) {
enemyDeaths();
}
function enemyDeaths() {
removeChild(Rocket);
trace("Rocket");
removeChild(enemyFleet[s]);
enemyFleet.splice(s, 1);
}
}
}
}
My error:
TypeError: Error #2007: Parameter child must be non-null. at
flash.display::DisplayObjectContainer/removeChild() at
Function/TrackermissileRocket190714002_fla:MainTimeline/letsgoeasy/TrackermissileRocket190714002_fla:follow()[TrackermissileRocket190714002_fla.MainTimeline::frame1:101]
My game image:
(1) You should make your vars as global (outside of and best before the functions part).
(2) Don't trap vars and functions inside other functions...
Try a setup similar to something like this:
//# globally declare the VARS (now available to all functions)...
var Rocket: Hawk;
var myTimer: Timer;
var RocketBox : Array = new Array;
var speedF: Number = 0;
stage.addEventListener(MouseEvent.CLICK, letsgoeasy);
function letsgoeasy(e: MouseEvent): void
{
speedF = 5;
Rocket = new Hawk();
Rocket.x = p.x;
Rocket.y = p.y;
Rocket.scaleX = Rocket.scaleY = 0.2;
Rocket.addEventListener(Event.ENTER_FRAME, moveBullet);
Rocket.addEventListener(Event.ENTER_FRAME, follow);
Rocket.addEventListener(Event.ENTER_FRAME, collCkeck);
addChild(Rocket);
RocketBox.push( Rocket );
myTimer = new Timer(2000); //# what for...?
myTimer.start(); //# maybe start Timer here at creation...?
}
function moveBullet(e: Event) : void
{
}
function follow( currRocket : Event) : void
{
//myTimer.start();
for (var h: int = 0; h < (enemyFleet.length-1); h++)
{
if (enemyFleet[h].y > 100)
{
currRocket.x -= (currRocket.x - enemyFleet[h].x) / speedF;
currRocket.x = currRocket.x + 2;
currRocket.y -= (currRocket.y - enemyFleet[h].y) / speedF;
currRocket.y = currRocket.y + 3;
//RocketBox.push( currRocket );
}
}
}
/////////
function collCkeck( currRocket : Event ) : void
{
for (var s: int = (RocketBox.length-1); s >= 0; s--)
{
if ( (s >= 0 ) && ( ( currRocket.hitTestObject(enemyFleet[s])) == true ) )
{
enemyDeaths( s );
}
}
}
function enemyDeaths( input_S ) : void
{
removeChild(Rocket);
trace("Removed... Rocket");
removeChild(enemyFleet[input_S]);
enemyFleet.splice(input_S, 1);
}

RangeError (index): Invalid value: Not in inclusive range 0..13: 14 Flutter

Someone to help me? I'm a beginner. I'm trying to get the controller numbers from a textfield. For this I tried to convert the characters to int. Note: in the textfield the user will enter numbers up to three digits
This error appears: RangeError (index): Invalid value: Not in inclusive range 0..13: 14
validate(textController)
{
List textCode = List();
List messageInCode = List();
int validateRepeticions;
var stringText = textController;
for (var b = 0; b < stringText.length; b++)
{
textCode.insert(b, stringText[b]);
}
validateRepeticions = textCode.length;
print(validateRepeticions);
int g = 0;
int k = 0;
do
{
bool comma = true;
List tryToParseInt = List();
int d = 0;// 'd' is responsible for identifying the positional value of a digit
int a = 1;// 'a' increment values to k
int c = 0;// 'c' defines the positions used in tryToParseInt
int completeNumber;
tryToParseInt.insert(c, int.tryParse(textCode[k]));
if (tryToParseInt[c] == null)
{
validateRepeticions--;
}
else
{
d++;
c++;
do
{
tryToParseInt.insert(c, int.tryParse(textCode[k+a]));
if (tryToParseInt[c] == null)
{
completeNumber = tryToParseInt[0];
messageInCode.insert(g, completeNumber);
g++;
comma = false;
validateRepeticions -= 2;
}
else
{
d++;
a++;
c++;
tryToParseInt.insert(c, int.tryParse(textCode[k+a]));
if (tryToParseInt[c] == null)
{
completeNumber = tryToParseInt[0]*10 + tryToParseInt[1];
messageInCode.add(completeNumber);
g++;
comma = false;
validateRepeticions -= 3;
d++;
}
else
{
d++;
completeNumber = tryToParseInt[0]*100 + tryToParseInt[1]*10 + tryToParseInt[2];
messageInCode.add(completeNumber);
g++;
comma = false;
validateRepeticions -= 3;
}
}
} while (comma);
}
d++;
k += d;
} while (validateRepeticions >= 0);
}
Updated code
validate(textEditingController) {
int validateRepeticions = textEditingController.text.length;
List textString = textEditingController.text.split('');
List messageInCode = List();
int k = 0;
do {
bool comma = true;
List tryToParseInt = List();
int d = 0; // 'd' is responsible for identifying the value of a number that has already been verified
int a = 1; // 'a' increment values to k
int c = 0; // 'c' defines the positions used in tryToParseInt
int completeNumber;
tryToParseInt.insert(c, int.tryParse(textString[k]));
if (tryToParseInt[c] == null) {
validateRepeticions--;
} else {
d++; //1
c++; //1
do {
tryToParseInt.insert(c, int.tryParse(textString[k + a]));
if (tryToParseInt[c] == null) {
completeNumber = tryToParseInt[0];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 2;
} else {
d++; //2
a++; //2
c++; //2
tryToParseInt.insert(c, int.tryParse(textString[k + a]));
if (tryToParseInt[c] == null) {
completeNumber = tryToParseInt[0] * 10 + tryToParseInt[1];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 3;
d++;
} else {
d++;
completeNumber = tryToParseInt[0] * 100 + tryToParseInt[1] * 10 + tryToParseInt[2];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 3;
}
}
} while (comma);
}
d++;
k += d;
} while (validateRepeticions > 0);
}
Now it's almost working, although an error still appears:
The method '_addFromInteger' was called on null.
Receiver: null
Tried calling: _addFromInteger(0)
validate(textEditingController) {
int validateRepeticions = textEditingController.text.length;
List textString = textEditingController.text.split('');
List messageInCode = List();
int k = 0;
messageInCode.clear();
do {
bool comma = true;
List tryToParseInt = List();
int d = 0; // 'd' is responsible for identifying the positional value of a digit
int a = 0; // 'a' increment values to k
int c = 0; // 'c' defines the positions used in tryToParseInt
int completeNumber;
if (k < textEditingController.text.length) {
tryToParseInt.insert(c, int.tryParse(textString[k]));
if (tryToParseInt[c] == null) {
validateRepeticions--;
} else {
d++; //1 these comments are examples
c++; //1
a++; //1
do {
if ((k + a) < textEditingController.text.length) {
tryToParseInt.insert(c, int.tryParse(textString[k + a]));
if (tryToParseInt[c] == null) {
completeNumber = tryToParseInt[0];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 2;
} else {
d++; //2
a++; //2
c++; //2
if ((k + a) < textEditingController.text.length) {
tryToParseInt.insert(c, int.tryParse(textString[k + a]));
if (tryToParseInt[c] == null) {
completeNumber = tryToParseInt[0] * 10 + tryToParseInt[1];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 3;
d++;
} else {
d++;
completeNumber = tryToParseInt[0] * 100 + tryToParseInt[1] * 10 + tryToParseInt[2];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 3;
}
} else {
completeNumber = tryToParseInt[0] * 10 + tryToParseInt[1];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 3;
d++;
}
}
} else {
completeNumber = tryToParseInt[0];
messageInCode.add(completeNumber);
comma = false;
validateRepeticions -= 2;
}
} while (comma);
}
} else {
validateRepeticions--;
}
d++;
k += d;
} while (validateRepeticions > 0 && k < textEditingController.text.length);
}
In your function, I'm assuming the param textController is the TextEditingController. In that case you need to check the length with textController.text.length
To create a list of characters from the string, you just need to use split() instead of creating a new list and loop through the string. For example: textController.text.split('')
Replace textCode.insert(b, stringText[b]); with textCode.add(stringText[b]);

Character never stops from walking

I am creating a game which uses andendgine and here is my code:
Player stanley = new Player();
...
scene.registerUpdateHandler(new IUpdateHandler() {
public void onUpdate(float pSecondsElapsed) {
stanX = stanley.getX();
destX = x.getX();
if(destX < stanX){
if(hasMovedRight == 1){
stanley.stop();
hasMovedRight = 0;
}
else{
stanley.moveLeft();
hasMovedRight = 0
hasMovedLeft = 1;
}
}
if(destX > stanX){
if(hasMovedLeft == 1){
stanley.stop();
hasMovedLeft == 0;
}
else{
stanley.moveRight();
hasMovedLeft = 0;
hasMovedRight = 1;
}
}
}
}
what i want is to stop Player from walking whenever his position X is equal to the touched area X. The problem is it never stop from walking. Thanks!
Your if statements are missing an element where destX == stanX. and you should really use else if. See modified code below.
if(destX + 8 < stanX){
if(hasMovedRight == 1){
stanley.stop();
hasMovedRight = 0;
}
else{
stanley.moveLeft();
hasMovedRight = 0
hasMovedLeft = 1;
}
}
else if(destX - 8 > stanX){
if(hasMovedLeft == 1){
stanley.stop();
hasMovedLeft == 0;
}
else{
stanley.moveRight();
hasMovedLeft = 0;
hasMovedRight = 1;
}
}
else //makes stanley stop. (calls stop method), if at touched x.
{
stanley.stop();
hasMovedRight = 0;
hasMovedLeft = 0;
}
try this one
setOnSceneTouchListener(new IOnSceneTouchListener() {
#Override
public boolean onSceneTouchEvent(Scene scene, TouchEvent event) {
int touchX = (int) (event.getX() - (sCHARStanley.getWidth() / 2));
//so that your sprite will go to the touched part of the screen
}

How I can create a pattern login like Android in HTML5?

I created the HTML5 version for the Pattern login like Android, but unfortunately I know not much of HTML5 as to give the required functionality.
How I can do that with the mouse can given action?
My project is this:
http://jsfiddle.net/atiruz/mvkv9/3/
var size = 3; // Dimensions -> 3x3.
var ancho = size * 82 + 10;
var alto = ancho;
var drawingCanvas = createCanvas(document.getElementById('canvas'), 600, 600);
var context = drawingCanvas.context;
context.beginPath();
CrearContenedor(context,0,0,ancho,alto,15);
for (var i = 1; i <= size; i++) {
for (var j = 1; j <= size; j++) {
CrearBoton(context, i * 80 - 32, j * 80 - 32, ancho, alto);
}
}
And the result is:
Here's a very basic (webkit only) canvas implementation: http://jsfiddle.net/ChfGh/1/
I'm using jQuery for event handling, but that isn't strictly necessary.
var can = $("#canvas")[0],
ctx = can.getContext('2d'),
wid = can.width,
hei = can.height,
pad = 20,
circles = [],
selCircs = [],
correctPath = [0,3,7,5,2],
startPoint = {
x: 0,
y: 0
},
dragging = false;
(function init() {
var rad = (wid - pad * 4) / 3;
for (var i = 0; i < 3; i++) {
for (var j = 0; j < 3; j++) {
circles.push(new Circle({
x: j * (pad + rad) + pad + rad / 2,
y: i * (pad + rad) + pad + rad / 2
}, rad / 2));
}
}
})();
(function draw() {
ctx.clearRect(0, 0, wid, hei);
for (var i = 0; i < circles.length; i++) {
circles[i].draw(ctx);
}
if (dragging && selCircs.length > 1) {
var pos = selCircs[0].circ.position();
ctx.beginPath();
ctx.lineWidth = 10;
ctx.strokeStyle = "#000";
ctx.moveTo(pos.x, pos.y);
for (var j = 1; j < selCircs.length; j++){
pos = selCircs[j].circ.position();
ctx.lineTo(pos.x,pos.y);
}
ctx.stroke();
}
webkitRequestAnimationFrame(draw);
})();
function Circle(center, radius, fill, stroke, hover, active) {
var center = {
x: center.x,
y: center.y
},
radius = radius,
fill = fill || '#ccc',
hover = hover || '#ddd',
active = active || '#0f0',
stroke = stroke || '',
path;
this.position = function(){
return {x:center.x, y:center.y};
}
this.draw = function(ctx) {
ctx.fillStyle = this.selected ? active : this.hovering ? hover : fill;
if (stroke) ctx.strokeStyle = stroke;
ctx.beginPath();
ctx.arc(center.x, center.y, radius, 0, Math.PI * 2, false);
ctx.fill();
if (stroke) ctx.stroke();
};
this.isPointInPath = function(x, y) {
return Math.sqrt(Math.pow(center.x - x, 2) + Math.pow(center.y - y, 2)) <= radius;
};
this.hovering = false;
this.selected = false;
}
$("#canvas").mousemove(function(e) {
for (var i = 0; i < circles.length; i++) {
var cir = circles[i];
var pip = cir.isPointInPath(e.offsetX, e.offsetY);
cir.hovering = pip;
if (dragging && pip && !cir.selected) {
selCircs.push({circ:cir, index:i});
cir.selected = true;
}
}
});
$("#canvas").mousedown(function(e) {
dragging = true;
});
$("#canvas").mouseup(function(e) {
dragging = false;
// validate path
if (selCircs.length == correctPath.length){
var valid = true;
for (var i = 0; valid && i < correctPath.length; i++){
var index = correctPath[i];
if (selCircs[i].index !== index) valid = false;
}
if (valid) alert('correct!');
}
// reset selection
for (var i = 0; i < selCircs.length; i++)
selCircs[i].circ.selected = false;
selCircs = [];
});​
Here's the style I ended up implementing for fun: http://jsfiddle.net/ChfGh/6/
You can use map to extract the indexes from the selected circles:
var path = selCircs.map(function(ele){
return ele.index;
}).join(" "); // " " if you want a space between, otherwise ""
It will give you a string representation of the input.
Checkout "Pattern Lock" jquery plugin at http://pagoenka.github.io/

Categories

Resources