Mouse over Effect Tutorial

Hi,

I'm facing a problem with this tutorial and it's torturing my mind.
link

I'm trying to make a title menu with two item "Play" & "Quit" highlighted when you hover with your cursor, exactly what's proposed with this tutorial. I understand that they are dynamically creating the animation name with the help of a prefix which is launched with a global AnimationSet linked to each button.

When I'm compiling no error is shown but when I'm launching the program it spits this:

[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMRd.ini]: Begin include @ASMR.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMR.ini]: Begin include @Title.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMR.ini]: End include @Title.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMR.ini]: Begin include @Inputs.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMR.ini]: End include @Inputs.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMR.ini]: Begin include @Player.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMR.ini]: End include @Player.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMR.ini]: Begin include @Crosshair.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMR.ini]: End include @Crosshair.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2781)] [ASMR.ini]: Begin include @Physics.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMR.ini]: End include @Physics.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2787)] [ASMRd.ini]: End include @ASMR.ini@
[19:34:14] [CONFIG] [orxConfig.c:orxConfig_ProcessBuffer(2676)] [ASMRd.ini]: <Display.Title> = ASMR -> ASMR (Debug)
[19:34:14] [LOG] 
* This template project creates a simple scene
* You can play with the config parameters in ../data/config/ASMR.ini
* After changing them, relaunch the executable to see the changes.
[19:34:14] [DISPLAY] [orxGraphic.c:orxGraphic_CreateFromConfig(815)] Couldn't get text or texture for graphic (StartButtonInactive).
[19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleAnimFromConfig(2241)] AnimSet [StartButtonAnimSet]: Failed to create anim [Inactive], couldn't retrieve associated texture's size.
[19:34:14] [DISPLAY] [orxGraphic.c:orxGraphic_CreateFromConfig(815)] Couldn't get text or texture for graphic (StartButtonActive).
[19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleAnimFromConfig(2241)] AnimSet [StartButtonAnimSet]: Failed to create anim [Active], couldn't retrieve associated texture's size.
[19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleFromConfig(2499)] AnimSet [StartButtonAnimSet]: Can't add link(s) starting from [Active]: source anim is missing.
[19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleFromConfig(2499)] AnimSet [StartButtonAnimSet]: Can't add link(s) starting from [Inactive]: source anim is missing.
[19:34:14] [ANIM] [orxAnimPointer.c:orxAnimPointer_SetCurrentAnim(1070)] 0 is not a valid ID for the anim pointer.
[19:34:14] [ASSERT] [orxAnimSet.c:orxAnimSet_ComputeAnim(3438)] FAILED ASSERTION [_u32SrcAnim < orxAnimSet_GetAnimCount(_pstAnimSet)]
Illegal instruction (core dumped) 

My ini

[Button]
Group           = UI

[ButtonAnimSet]
KeyDuration     = 1
StartAnim       = Inactive
Inactive        = # 0
Active          = # 0
Inactive->      = Inactive # .Active
Active->        = Active # +.Inactive

[StartButton@Button]
Graphic         = StartButtonInactive1
AnimationSet    = StartButtonAnimSet
Position        = (0,50,-1)
Pivot           = center
Scale           = 1

[StartButtonAnimSet@ButtonAnimSet]
Prefix          = StartButton

[StartButtonInactive1]
Texture         = Ui/Start_Inactive.png
TextureOrigin   = (0,0,0)
TextureSize     = (256,256,0)

[StartButtonActive1]
Texture         = Ui/Start_Active.png
TextureOrigin   = (0,0,0)
TextureSize     = (256,256,0)

My Function called in orxUpdate

void _menuHover()
{
    orxOBJECT *currentObj;
    orxVECTOR cursorPos;
    if(orxRender_GetWorldPosition(orxMouse_GetPosition(&cursorPos),orxNULL,&cursorPos) != orxNULL)
    {
        currentObj = orxObject_Pick(&cursorPos,orxString_GetID("UI"));
    }
    
         if(currentObj != previousObj)
    {
        if(previousObj != orxNULL)
        {
            orxObject_SetTargetAnim(previousObj, orxNULL);
        }
        
                if(currentObj != orxNULL)
        {
            orxObject_SetTargetAnim(currentObj, "Active");
        }
        
        previousObj = currentObj;
    }
}

Finally don't know if it's relevant or not, I'm working on Ubuntu 20.04 and CodeLite.

I've tried lots of things and nothing worked, so any help is appreciated.

Thanks in advance.

Comments

  • Hi @DrTdb,

    From the error log you posted, the interesting lines are:

    [19:34:14] [DISPLAY] [orxGraphic.c:orxGraphic_CreateFromConfig(815)] Couldn't get text or texture for graphic (StartButtonInactive).
    [19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleAnimFromConfig(2241)] AnimSet [StartButtonAnimSet]: Failed to create anim [Inactive], couldn't retrieve associated texture's size.
    [19:34:14] [DISPLAY] [orxGraphic.c:orxGraphic_CreateFromConfig(815)] Couldn't get text or texture for graphic (StartButtonActive).
    [19:34:14] [ANIM] [orxAnimSet.c:orxAnimSet_CreateSimpleAnimFromConfig(2241)] AnimSet [StartButtonAnimSet]: Failed to create anim [Active], couldn't retrieve associated texture's size.
    

    Orx complains it can't create the graphics you requested for both animations (Inactive and Active).
    Looking at your config data, I see:

    [StartButtonInactive1]
    Texture         = Ui/Start_Inactive.png
    TextureOrigin   = (0,0,0)
    TextureSize     = (256,256,0)
    
    [StartButtonActive1]
    Texture         = Ui/Start_Active.png
    TextureOrigin   = (0,0,0)
    TextureSize     = (256,256,0)
    

    Are those files paths correct (they need to be case-sensitive as well, given you're running on linux)?
    Do you have any Resource section defined somewhere else that we do not see here? If not, the paths you're using will be relative to the executable's location.
    If the paths seem correct, it might be that orx isn't able to load your images. Maybe try to save them with a different application, sometimes some applications don't fully respect image formats when writing them.

    Side note: if you plan on using the entire images, there's no need to define TextureOrigin and TextureSize, as the default behavior is to use the full image for a texture.

  • Hi, Thanks for answering.

    The file path and the files are correct since I've tried to load them with simply an [Object] and a [Graphic], creating them in the INIT phase and it worked, plus they're not the first assets I use in this project created with the same method. No hidden resource section either.

    I call a function in the init phase creating the [StartButton]

    
    void _setTitle()
    {
        orxObject_CreateFromConfig("TitleObject");
        orxObject_CreateFromConfig("OrxLogoObject");
        orxObject_CreateFromConfig("StartButton");
        //orxObject_CreateFromConfig("QuitButtonInactiveObj"); 
    }
    

    And

    
    orxSTATUS orxFASTCALL Init()
    {
        orxViewport_CreateFromConfig("MainViewport");
    
        _setTitle();
    
        orxClock_Register(orxClock_Get(orxCLOCK_KZ_CORE), Update, orxNULL, orxMODULE_ID_MAIN, orxCLOCK_PRIORITY_NORMAL);
    
        return orxSTATUS_SUCCESS;
    }
    

    Maybe it's not the right method or the right place to call for [StartButton] ?

  • You're correct, I read the error message too fast. After having a closer look, I believe the tutorial is incorrect.
    I'll need to give it a try on my side tonight, but if you want to test it on yours, here's how I'd define the config, had I to do it myself:

    [Button]
    Group           = UI
    
    [ButtonAnimSet]
    KeyDuration     = 0.1
    FrameSize       = (256, 256)
    StartAnim       = Inactive
    Inactive->      = Inactive # .Active
    Active->        = Active # +.Inactive
    
    [StartButton@Button]
    AnimationSet    = StartButtonAnimSet
    Position        = (0,50,-1)
    Pivot           = center
    Scale           = 1
    
    [StartButtonAnimSet@ButtonAnimSet]
    Prefix          = StartButton
    
    [StartButtonInactive]
    Texture         = Ui/Start_Inactive.png
    
    [StartButtonActive]
    Texture         = Ui/Start_Active.png
    

    I'm not 100% sure it'll work until I test it though, as I typed it in the forum.

  • As a side note, seeing your _setTitle function, I'd recommend using an object hierarchy for easier handling:

    void _setTitle()
    {
        orxObject_CreateFromConfig("StartMenu");
    }
    
    [StartMenu]
    ChildList = TitleObject # OrxLogoObject # StartButton
    
  • I've tried the solution you typed and it's better (less error), the viewport is back with the background and logo but still the StartButton is a no-show and it give me this :

    [09:24:55] [DISPLAY] [orxGraphic.c:orxGraphic_CreateFromConfig(815)] Couldn't get text or texture for graphic (StartButtonInactive1).

    Then, I tried force feeding him :

    
    [Button]
    Group           = UI
    
    [ButtonAnimSet]
    KeyDuration     = 0.1
    FrameSize       = (256,256)
    StartAnim       = Inactive
    Inactive->      = Inactive # .Active
    Active->        = Active # +.Inactive
    
    [StartButton@Button]
    AnimationSet    = StartButtonAnimSet
    Position        = (0,50,0)
    Pivot           = center
    Scale           = 1
    
    [StartButtonAnimSet@ButtonAnimSet]
    Prefix          = StartButton
    
    [StartButtonInactive]
    Texture         = Ui/Start_Inactive.png
    
    [StartButtonInactive1]
    Texture         = Ui/Start_Inactive.png
    
    [StartButtonActive]
    Texture         = Ui/Start_Active.png
    
    [StartButtonActive1]
    Texture         = Ui/Start_Active.png
    

    No more error, viewport is showing with everything in it except for this [StartButton] from hell.

    Next I've tried to remove [StartButtonInactive] & [StartButtonActive] and it's back to square one, lots of error and no more viewport.

    Back to the previous state (the almost working one), I've tried messing with the MainCamera FarFrustum and the Z axis and I'm still stuck, bummer. I will get back on it this afternoon.

    Thanks for the side note, it's much much cleaner this way.

  • edited June 2020

    Hi again,

    Another way to fix that message is to give the object a Graphic:

    [StartButton]
    Graphic = StartButtonInactive
    

    In any case, that's not the issue preventing you from seeing your object. As you've already verified if your object is inside your camera's frustum, we should be good on this side. So lastly, does your camera render the UI group?
    You need to check your camera's GroupList and verify UI is part of it. If you don't have any GroupList on it, your camera only renders the default group.

    This wiki entry should help with this part: https://wiki.orx-project.org/en/tutorials/viewport_heads_up_display

  • Hi !
    It's working ! You were right I forgot to set my [ButtonGroup] in my [MainCamera] group list, the tutorial you provided helped.
    But it was not all, I had to swap

    GroupList        = ButtonGroup # default

    to

    GroupList        = default # ButtonGroup

    The first one wasn't showing the button, the second did, it seems like there is some sort of order or priority to follow.

    Nonetheless, thanks a lot, I'm now back on track.

  • edited June 2020
    Ah yes, forgot to mention groups are rendered in the order you define them, which allows you to make sure your ui is always rendered on top, for example. They can be thought of as layers in that respect.

    I'm glad you're back on track. Don't hesitate if you have any other questions.
Sign In or Register to comment.