B4J Question SetLayoutAnimated End using

Discussion in 'B4J Questions' started by ElliotHC, Jun 4, 2019.

  1. ElliotHC

    ElliotHC Active Member Licensed User

    In my game I'm generating images that are falling down the screen.

    I'm using SetLayoutAnimated and I'm making (image.visible = false) when I'm finished using it.

    Is that all I need to do because things are slowing down after my game has been running a while...
     
  2. sorex

    sorex Expert Licensed User

    are the images re-used (placed at the top again and dropping) ?

    if not you better remove the view.
     
  3. ElliotHC

    ElliotHC Active Member Licensed User

    Yes, I am using the same images but cycling through 1 = 10 im (ImageViews)

    Question is, is just hiding them messy?
     
  4. ElliotHC

    ElliotHC Active Member Licensed User

    I need to make sure I'm clearing down anything in my code. Do you know if there is a section on correctly disposing stuff?
     
  5. sorex

    sorex Expert Licensed User

    if you don't create new ones I don't really see why things slow down after a while.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    The question is not clear.
     
  7. ElliotHC

    ElliotHC Active Member Licensed User

    I think I'm creating new ones each time. I guess once I've created that image and want to take it back up to the start once it's dropped..

    Is AddNode creating it again, or just moving it?

    My App is racking up some serious memory so something isn't right
     
  8. ElliotHC

    ElliotHC Active Member Licensed User

    Code:
    im.Initialize("C:/Smash","BACKGROUND_SECTION.png")
                SECTION1.Initialize(
    "SECTION1")
                SECTION1.SetImage(im)
                MainForm.RootPane.AddNode(SECTION1,
    230,Image_Start_Point - 80,614,254)
                
    Dim jo As JavaObject = SECTION1 ' the imageview
                Dim o As Object = jo.CreateEvent("javafx.beans.value.ChangeListener","moved",False)
                jo.runmethodJO(
    "layoutYProperty",Null).RunMethod("addListener",Array(o)) ' make sure you choose property that will change
                SECTION1.SetLayoutAnimated(Image_Speed,230,Image_Bottom_End - 80,614,254' left/right up/down
    If I wanted to create the image but keep re-using it, which part of this code do I use again?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    1. Load the image once and reuse it.
    2. Whenever you call ImageView.Initialize, you create a new view.
     
  10. ElliotHC

    ElliotHC Active Member Licensed User

    Thanks Erel

    How do I set the image back to the start position ready for the next animation?

    Another animate but with zero duration?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Code:
    SECTION1.SetLayoutAnimated(Image_Speed,230,Image_Bottom_End - 80,614,254)
    Sleep(Image_Speed + 
    10)
    SECTION1.SetLayoutAnimated(
    01020614254)
     
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