harrywatson Posted May 2, 2014 Share Posted May 2, 2014 Hi all, I'm trying to store coordinates in an array and cycle through them on click. I've stored the coordinates in an array and the event listener obediently changesthe y coordinate of my image but using the array index rather than the given values.IE 0,1,2,3 instead of 50 -50 -150 -250posa = 50;posb = -50;posc = -150;posd = -250; position = [posa, posb, posc, posd];index = 0;clue1.addEventListener("click", function(event) {//clue1.y = posb;///////worksclue1.y = (index++)%(position.length);//alert(position);/////returns 50 -50 -150 -250//alert(clue1.y):////returns 0 1 2 3stage.update();});You can see it not working here. You may have to reload as there is no preloading: http://harrywatson.altervista.org/combination.html Many thanks to those who take a look Quote Link to comment Share on other sites More sharing options...
harrywatson Posted May 3, 2014 Author Share Posted May 3, 2014 EL FIXOROONABLIE!!!! Hooray! clue1.y = position[(index++)%(position.length)]; http://harrywatson.a...ombination.html Quote Link to comment Share on other sites More sharing options...
harrywatson Posted May 3, 2014 Author Share Posted May 3, 2014 When I've completed my combination lock code I'll post it in 'show and tell' for other simpletons like me to use. :-) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.