Jump to content

inverting/flipping puzzle pieces on hover?


Laurelin
 Share

Recommended Posts

Hello! I'm making a puzzle game, and I'm attempting to have the effect where you can put your mouse over a puzzle piece and use the keyboard keys to flip it, invert it, etc. I can't just have the game outright rotate a sprite, because it'll look backwards when it's backwards. 

 

So I have four different images of the same piece, one regular, one flipped horizontally, one flipped vertically, one flipped both. There are six pieces - for now, it's a demo/tutorial thing. 

 

So I'm asking questions to make the code less terrible. 

 

First, is there a way for the game to tell which image is currently being used for a sprite? I'm using a JSONHash sheet. 

 

Second, I want to .onInputOver.add(function, this) the same function for whole bunch of pieces. But it needs to know which piece is being hovered over. Is there a simple way? Do I have to do that ugly passing arguments to a function that's inside of an argument thing? Can it tell which sprite called it?

 

I've tried looking at the docs, not sure I'm any good at reading them, though, as the answer seems to be no.

 

Maybe it'd be easier if I added some custom variables to each sprite, like isFlipped, isInverted. 

 

Thank you!

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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