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

Bug Report: FlxMouseEventManager doesnt work on codename #371

Open
NotMrPolo-real opened this issue Aug 18, 2024 · 4 comments
Open

Bug Report: FlxMouseEventManager doesnt work on codename #371

NotMrPolo-real opened this issue Aug 18, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@NotMrPolo-real
Copy link

[X] Windows
[ ] Linux
[ ] Mac

i've been using FlxMouseEventManager in psych engine a lot of time and it works always but when i try it in codename it just doesnt detect or go into the functions i want.
does anybody know why?

@NotMrPolo-real NotMrPolo-real added the bug Something isn't working label Aug 18, 2024
@Hackx2
Copy link

Hackx2 commented Aug 28, 2024

I haven't used FlxMouseEventManager that much, so I cannot give you an answer, but here is a solution:

FlxG.mouse.overlaps(SprOrGrp:FlxBasic, ?Camera:Null<FlxCamera>) : Bool
FlxG.mouse.justPressed(get, never) : Bool

like:

override function update(elapsed:Float){
    super.update(elapsed);

    if(FlxG.mouse.overlaps(spr, /*If the sprite in question is using a camera, put it here.*/)){
        if(FlxG.mouse.justPressed){
            // justPressedCode
        }
        // selectedCode
    } else {
       // nonSelectedCode
    }
}

@NotMrPolo-real
Copy link
Author

NotMrPolo-real commented Aug 28, 2024

ty but the reason i really need the FlxMouserEventManager to work is because so when i hover(overlaps) a object(spr) it plays the scroll sound.
when i try it with the normal FlxG.mouse.overlaps(spr) the sound is looped until i un-hover.

@Hackx2
Copy link

Hackx2 commented Aug 28, 2024

Hopefully, this works. :3c

var hasSoundPlayed:Bool = false;

override function update(elapsed:Float) : Void {
    super.update(elapsed);

    if(FlxG.mouse.overlaps(/* Sprite u wanna click */, /*If the sprite in question is using a camera, put it here.*/)){ // Selected
        if(!hasSoundPlayed){
            // Plays the sound once
            FlxG.sound.play(/*soundPath*/);
            hasSoundPlayed = true;
        }
        if(FlxG.mouse.justPressed){
            // justPressedCode
        }
        // selectedCode
    } else { // Not Selected
       hasSoundPlayed = false;
       // nonSelectedCode
    }
}

I'm half asleep, so if it doesn't work, put the hasSoundPlayed variable inside the update function.

@ItsLJcool
Copy link
Contributor

99% sure the reason why its broken in CNE is because the Flixel branch they custom made for CNE was outdated (This i know because of a UIState bug that pissed me off 😭) and It works in original YoshiCrafterEngine, and very old (like first 100 commits) CNE because it was using updated Flixel branch.

@NeeEoo might want to check flixel branch and see why FlxMouseEventManager doesn't actually work. Don't know the reason but if I remember, FlxMouseEventManager imports don't work, and i think FlxMouseEventManager.add is null or smth.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants