Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oscillating pin image when it collides with any of the separator #6

Closed
M-I-N opened this issue Jul 6, 2020 · 7 comments
Closed

Oscillating pin image when it collides with any of the separator #6

M-I-N opened this issue Jul 6, 2020 · 7 comments
Labels
enhancement New feature or request

Comments

@M-I-N
Copy link
Contributor

M-I-N commented Jul 6, 2020

Can the pin image be oscillated?

Actually it should be like, the pin image rotates +θ / -θ degrees (depending on the direction of wheel rotation) and move back to original immediately after the collision imitating an oscillation effect.

I think a better visualisation would be these screenshots:
Screenshot 2020-07-07 at 12 18 02 AM
Screenshot 2020-07-07 at 12 22 04 AM

@sh-khashimov
Copy link
Owner

Do you mean a similar effect like on this project right?
Need to think it over, because now the pin image is optional, as well as anchor images. Also if a collision effect must be done relative to an anchor, there can be zero or two anchors at the same time, the position of the anchor could be anywhere with vertical and radian offset.

@sh-khashimov sh-khashimov added the enhancement New feature or request label Jul 6, 2020
@M-I-N
Copy link
Contributor Author

M-I-N commented Jul 7, 2020

Do you mean a similar effect like on this project right?

Yes, kind of.

Also if a collision effect must be done relative to an anchor, ...

Actually, I'm not interested for the anchor images. Can the collision effect be done relative to the separator between two slices? If yes, then I think your concern about "there can be zero or two anchors at the same time" can be left aside.

See this:
Screenshot 2020-07-07 at 12 18 02 AM 2

In my case I need to have the collision effect whenever the Pin Image is being passed through by the purple lines (separator line to be exact).

@sh-khashimov
Copy link
Owner

I will take into consideration this feature for future releases. Nevertheless, right now I can not announce the date when this will be done.

@M-I-N
Copy link
Contributor Author

M-I-N commented Jul 7, 2020

Okay. Great.

But can you consider adding a call back for any collision between the Pin & Separator?
So that I can take action from the client side and maybe mimic the oscillation effect from the client side. And also some other actions like playing a collision sound or do a vibration.

Something like below will be extremely helpful for my case:

public class SwiftFortuneWheel: UIControl { 
    . . .
    enum Rotation {
        case clockwise
        case counterClockwise
    }
    . . . 
    public var onCollisionWithSeparator: ((Rotation) -> Void)?
    . . . 
}

With that, I can use it at the client side like:

fortuneWheel.onCollisionWithSeparator = { rotation in 
    // TODO: play a sound / vibrate
    // TODO: maybe implement a Pin image (added in the client side) collision 
}

If you don't think you can focus on this right now, can you please give me a head start for calculation of collision detection?

@sh-khashimov
Copy link
Owner

I don't mind if you start.

Do you have any idea, besides animation and sound, can this closure be useful for something else, that doesn't relate to SwiftFortuneWheel itself?

In my opinion, it is better to implement these features, not on the client-side, but how a quick and temporary solution I don't mind.

sh-khashimov added a commit that referenced this issue Nov 12, 2020
@sh-khashimov
Copy link
Owner

Added: https://github.com/sh-khashimov/SwiftFortuneWheel/blob/master/Documentation/collision.md

@M-I-N
Copy link
Contributor Author

M-I-N commented Nov 17, 2020

@sh-khashimov you are the man! Thanks a ton for this added feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants