Jump to content

How do you guys make your screen cursor?


isfuturebright
 Share

Recommended Posts

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. 

 

Aladdin_(SNES)-title.png

 

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

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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...