isfuturebright Posted October 31, 2013 Share Posted October 31, 2013 On a screen with options like PLAY - OPTIONS - QUIT, how do you guys control your cursor? Is there a way in phaser for it? Without using mouse events. Link to comment Share on other sites More sharing options...
rich Posted October 31, 2013 Share Posted October 31, 2013 You mean a custom cursor? Or something else? Link to comment Share on other sites More sharing options...
isfuturebright Posted October 31, 2013 Author Share Posted October 31, 2013 No I mean is there a class that I can add to that handles a set of positions to move through like it was moving in a menu? How would you go by doing this? Link to comment Share on other sites More sharing options...
rich Posted October 31, 2013 Share Posted October 31, 2013 Still not really sure what you're after, sorry. Maybe post a screen shot or something if it'll help? Link to comment Share on other sites More sharing options...
isfuturebright Posted October 31, 2013 Author Share Posted October 31, 2013 Lemme see if this code helps this.cursor = {}; this.cursor.currentLine = 0;//Curent item the cursor is at this.cursor.maxLine = 3;//Number of itens the cursor will cycle through this.cursor.positions = {}//Points that store the position of each item this.cursor.updatePosition = function(key) { if(keyPressed(key) == Phaser.Keyboard.UP) { if(this.cursor.currentLine == 0) this.cursor.currentLine = this.cursor.maxLine; else this.cursor.currentLine -= 1 } else{ //DOWN-LEFT-RIGHT... } };I used to do something like this when using as3. I had this class that made it easier to make an animated cursor that would cycle through the given positions I gave. I would update the cursor given it a key value and he would update his position (line/column). My cursor back then was basically a FlxSprite with a specific behavior, yet very customizable. It would end up like a cursor like this one above. I was wondering if Phaser has something like that / I'm doing this in a good way xD Link to comment Share on other sites More sharing options...
Mike Posted October 31, 2013 Share Posted October 31, 2013 Well, the "genie hand" looks to me like just a simple sprite with some custom logic and in the above screenshot just 3 positions. So did you tried making a custom sprite class which will hold this custom logic... or am I missing something more complicated behind this...? Link to comment Share on other sites More sharing options...
rich Posted November 1, 2013 Share Posted November 1, 2013 Alrighty, gotcha Like a Button Group I guess? That you could cycle through with key presses? It doesn't have that feature built in directly I'm afraid, sorry! At least it didn't until an hour ago, but now it does Currently in the dev branch 1.1.2: * New: Added Group.cursor. This points to the first item added to a Group. You can move the cursor with Group.next() and Group.previous(). Link to comment Share on other sites More sharing options...
isfuturebright Posted November 1, 2013 Author Share Posted November 1, 2013 Well, the "genie hand" looks to me like just a simple sprite with some custom logic and in the above screenshot just 3 positions. So did you tried making a custom sprite class which will hold this custom logic... or am I missing something more complicated behind this...?Yeah that's basically what I used to do. I was just wondering if there is a better way to do it/Phaser has a built in option. Alrighty, gotcha Like a Button Group I guess? That you could cycle through with key presses? It doesn't have that feature built in directly I'm afraid, sorry! At least it didn't until an hour ago, but now it does Currently in the dev branch 1.1.2: * New: Added Group.cursor. This points to the first item added to a Group. You can move the cursor with Group.next() and Group.previous().Will look into it rich! Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts