B4A Library [B4X] [XUI] SD SlidingPuzzleView (With source code)

Discussion in 'Additional libraries, classes and official updates' started by Star-Dust, May 26, 2018.

  1. Star-Dust

    Star-Dust Expert Licensed User

    I was envious of @Johan Schoeman 's SlidingPuzzle library that you find here.
    So I decided to recreate it for B4X inspired by the same library.

    I have attached the source code, I entered a procedure to shuffle the cards.

    upload_2018-5-26_22-19-22.png upload_2018-5-26_22-18-38.png 1.gif

    Code:
    Sub Activity_Create(FirstTime As Boolean)
        
    'Do not forget to load the layout file created with the visual designer. For example:
        Activity.LoadLayout("Layout1")
     
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub SlidingPuzzleView1_Solved
        
    ToastMessageShow("Solved",True)
    End Sub

    Sub Button1_Click
        SlidingPuzzleView1.Solve
    End Sub
     

    Attached Files:

    Last edited: May 27, 2018
  2. Star-Dust

    Star-Dust Expert Licensed User

    I made an update to make it totally XUI, I realized later that a function did not use XUI methods.
    I have also included the possibility of writing numbers in the cards and establishing the color of the text. I improved the mixing algorithm
     
    Last edited: May 27, 2018
  3. MarcoRome

    MarcoRome Expert Licensed User

    Well done Star
     
    Star-Dust likes this.
  4. Lucas Eduardo

    Lucas Eduardo Member Licensed User

    Hello, that's a great Class :D. I was testing and i found a bug, when i change the Number Grid in the designer it doesn't work. It just work if i change too the
    Code:
    Private Cateto As Int = 5
    to the same value
     
  5. Star-Dust

    Star-Dust Expert Licensed User

    It is a knowledge imposed the maximum limit to 4, I forgot to document it. But if you need it I can increase to 5
     
  6. Lucas Eduardo

    Lucas Eduardo Member Licensed User

    Yes, i would like it a lot and if possible increase to 6.
    Thank you :)
     
  7. Lucas Eduardo

    Lucas Eduardo Member Licensed User

    I found too when i was testing
    Code:
    Sub SlidingPuzzleView1_Solved
       
    ToastMessageShow("Solved",True)
    End Sub
    This sub doesn't work, i was getting an error, so i add this parametter
    Code:
    (Move As Int)
    and worked perfectly
     
  8. Star-Dust

    Star-Dust Expert Licensed User

    Update rel. 0.02 Fix Bug
     
    Lucas Eduardo likes this.
  9. Lucas Eduardo

    Lucas Eduardo Member Licensed User

    Is there a way to change the number grid by code?
     
  10. Star-Dust

    Star-Dust Expert Licensed User

    Not currently. The class creates the image grid at the time of initialization. Absorbs the image from the Background property and splits it into the various boxes.
    Changing after the number of rows / columns would have no effect.

    A new method should be created (eg SetBoxNumber(Cateto as int)) which redoes the subdivision operation for the new value and re-draw.

    I put the code so that everyone can make the improvements he wants.
     
    Almora likes this.
  11. Lucas Eduardo

    Lucas Eduardo Member Licensed User

    I got it :D. Thank you.
     
  12. Star-Dust

    Star-Dust Expert Licensed User

    Update rel 0.03
    Bugs fix to improve compatibility with B4i
     
    Peter Simpson and Erel like this.
  13. Almora

    Almora Active Member Licensed User

    hi..
    pictures added to the designer. I need to create my new designer every time for different pictures.
     
  14. Star-Dust

    Star-Dust Expert Licensed User

    Now I'm off-site. I will try to answer in the next days
     
    Almora likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice