Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
nicolasbulgarides
@nicolasbulgarides
@ImperaEtConquer thank you! :-)
Chengen Zhao
@chengenzhao
@nicolasbulgarides thx, I knew get game scene allows us to change the cursor but it seems like not work during the resources loading screen.
I tried to change the cursor in initSettings method but it doesn't allow me to do that, so I have to change the cursor in initInput method but in this way, during the resources loading screen, the cursor will remain the blue triangle
if I set the experimental native to true, then the cursor will change to system default cursor during the resources loading screen
Chengen Zhao
@chengenzhao
  @Override
  protected void onUpdate(double tpf) {
    if(firstInit){
      firstInit = false;
      getGameScene().getInput().setRegisterInput(false);
      getGameController().pauseEngine();
      onFinished.onInitFinished();//callback to enable javafx init pane
      return;
    }
currently we use this mechanism to avoid the conflict of JavaFX pane actions and FXGL game initialization
If embedded launch method could provide a callback of initialization then it will simpler to implement this mechanism
e.g.
GameApplication.embeddedLaunch(game, () -> {...}); //2nd parameter is onFinish callback
Chengen Zhao
@chengenzhao
I tried onMainLoopStarting and onInit to pause the engine but it doesn't work
Chengen Zhao
@chengenzhao
Improved, use EngineService onGameReady method to implement that mechanism
    private static boolean firstInit = true;

    @Override
    public void onGameReady(PropertyMap vars) {
        super.onGameReady(vars);
        if(firstInit){
            FXGL.getGameScene().getInput().setRegisterInput(false);
            FXGL.getGameController().pauseEngine();
            Main.enableInitPane();
            firstInit = false;
        }
    }
Chengen Zhao
@chengenzhao
Could be a good idea for Engine Service provide a post init method
Chengen Zhao
@chengenzhao
Is there any examples for freezed background? for example if we move the viewport but the background image or entity is still there.
Like background mountains far from where characters stand, if we move the character it won't move the background mountains also
Almas Baimagambetov
@AlmasB

@phi-whiterabbit Hi, I think x,y became read only to avoid issues with viewport effects, such as shake. How about binding the viewport to a "ghost" entity and moving that entity? Should give the same effect.

As for bindToFit, I can see it is commented out -- I may have forgotten to migrate it to 11+. Please can you open an issue, so this gets tracked and fixed. If you need it now, here it is commented out, you might be able to patch it from outside of FXGL given all of the calls made seem to be publicly accessible

@chengenzhao Re: init callback for embedded mode, good idea -- I also encountered this issue when I tried to build an app this way. It's currently tracked via an inlined TODO, so I will open an issue for this
Almas Baimagambetov
@AlmasB

Seems like if we enable experimental native, then the default cursor will remain the system default cursor but no idea why

experimentalNative should go away soon since we now support native (that is running on mobile and desktop with native libs). If we are running natively, FXGL will safeguard certain areas, such as font loading, particle effects, as these may not be ready on all platforms.

Chengen Zhao
@chengenzhao
I think I know how to solve loading issue
It should be via scene factory, using new loading scene method
Almas Baimagambetov
@AlmasB
each FXGLScene has its own cursor, so they all need to be updated one by one: StartupScene (probably dont need to, this is typically quick), IntroScene, LoadingScene, GameScene
If you think we should have a default cursor, which will be set to all scenes at the start, feel free to create an issue for this

Like background mountains far

I guess you could bind its x,y to viewport x,y?

Chengen Zhao
@chengenzhao
Sure, I think it would be a good idea to allow user to set a global cursor in initSettings method
Chengen Zhao
@chengenzhao
@AlmasB Good Afternoon, for loading scene, is there any fade in/out effect when the scene exit to another scene like from loading scene to game scene, could it be possible to fill in fade in/out effect? like loading scene fade out and game scene fade in?
Besides, I tried to follow the default loading scene implementation, and seems like the progress number is always set to -1.0, could it be possible to show the progress of resources loading?
Chengen Zhao
@chengenzhao
I tried to utilize onExistingTo and onDestroy method, but it doesn't work
  @Override
  public void onExitingTo(Scene nextState) {
    FadeTransition ft = new FadeTransition(Duration.millis(1000), getContentRoot());
    ft.setFromValue(0.0);
    ft.setToValue(1.0);
    ft.play();
    ft.setOnFinished(e -> {
      super.onExitingTo(nextState);
    });
  }
Chengen Zhao
@chengenzhao
It would be nice to have transition between different scenes
maybe: transiteTo(Scene nextState)
Ged223
@Ged223
image.png
I can't seem to find any way to change the volume of music that actually works. Maybe I am just blind, but this is the only thing I found so far that actually compiles, though it doesn't change volume :(
phi-whiterabbit
@phi-whiterabbit
@AlmasB: Nice idea to use a ghost entity.
@AlmasB: cconcerning bindToFit i will file a corresponding feature request, and adapt the commented out implementation. Thanks.
Almas Baimagambetov
@AlmasB
@chengenzhao You can produce a custom implementation of the Loading scene and change it as needed. You can apply fade-in effect in onCreate() but fade-out effect has to happen in a different scene before the scene change is called.
So, when scene is done, play fade out, when animation is done, change scene
@Ged223 Example here. In short, use getSettings()....
Chengen Zhao
@chengenzhao
@AlmasB We created an finished pane and add it to the next scene content root, and then fade out this pane and the underneath game scene is automatically fade in
jmaler
@jmaler
Hi @AlmasB, I am creating MainMenu with several options to select before starting a new game. What is the intended way how to pass the parameters from menu to initGame() method?
In menu, I can call FXGL.getGameController().startNewGame(); but there are no params for passing.
Thank you.
Almas Baimagambetov
@AlmasB
@jmaler Hia, I would use a service for this, example
class MyService extends EngineService {

}

settings.addService(MyService.class);
in your menu you would update the service with anything you need, in your game you would access the service and obtain that data
blueskyonmars
@blueskyonmars
image.png
Anyone notice that when opening GeoWarsApp.java in an Intellij project, buildAndPlay() is flagged as not resolvable? It builds OK from maven. Is it something I did wrong when opening the GeometryWars project? Or a known Intellij issue?
Almas Baimagambetov
@AlmasB
Same here, started seeing this lately, but can't quite pinpoint the issue to report it.
The project runs fine from intellij and from the command line, but the syntactic analysis seems to think something is wrong
nicolasbulgarides
@nicolasbulgarides
Hi @AlmasB , hope things are well. I have a question about how FXGL app / scene set-up interacts with the robot createCapture function. I am successful in using the robot class to take a screenshot of the FULL screen, outside of app window, but this setup has the unintended consequence of requiring a shift to fullscreen then a shift back out to have a screenshot that is only the application window. Mind you, I am not writing these images, im displaying them in ImageViews for the user. Tying this back to FXGL, when I try to use the .snapshot on any node, I get an exception relating to the threading of the window Caused by: java.lang.IllegalStateException: Not on FX application thread; currentThread = FXGL Background Thread 4, and I have tried using the FXGL.getGameScene.getContentRoot and .getRoot. Its odd that there is this interaction considering the full screenshot with rectangle bounds works but just one specific node doesn't....if you have an idea on how to the .snapshot method, or another way of taking a screenshot of just the application window without writing it, please let me know. Thank you :-)
Almas Baimagambetov
@AlmasB
Hi, if fxgl is running natively you can take a screenshot from the mainwindow object. In embedded mode the API is the same but not implemented yet, please raise an issue if that's the case.
Your external approach should also work fine, just need to call from the javafx thread, not FXGL's
0BlueLvr3h
@0BlueLvr3h
I'm making a 2d platform game and i wanted to know how to make different events happen depending on which side of the entities the collision happens. Think of a goomba from Super Mario, how depending on where the collision happens, the player either takes damage or kills the goomba.
pls help :)
Юрий Лавринов
@yuralavrinov:matrix.org
[m]
good day to all, first of all I wanted to say thank you for FXGL, and secondly I wanted to ask about testing my application, whether there are any tutorials or you can give me advice on how to at least write tests, thank you in advance)
@0BlueLvr3h: I still don't know much and maybe there is such an option, but if not, then I would just compare the coordinates of the player and the object
Almas Baimagambetov
@AlmasB
@0BlueLvr3h You can add multiple HitBox objects to your player and then use onHitBoxTrigger() collision callback from your collision handler.

@yuralavrinov:matrix.org I suppose it depends on what you wish to test.

For unit tests, you'd mostly test your own classes, so pick up something like JUnit 5 and you are good to go.

As for other types, I haven't considered integration / system tests with FXGL yet. You probably will need to have a @BeforeAll that works for all tests, so you can start FXGL once, run your tests, then shut FXGL down.

Almas Baimagambetov
@AlmasB
@/all FYI, we now have GitHub Discussions up and running, so feel free to post ideas and questions there
0BlueLvr3h
@0BlueLvr3h

@0BlueLvr3h You can add multiple HitBox objects to your player and then use onHitBoxTrigger() collision callback from your collision handler.

do I have to use tiled or can i do it through code?

Юрий Лавринов
@yuralavrinov:matrix.org
[m]
@AlmasB For example, I want to test the movement of a player, how can I do this ? if you do as I do, it compares the coordinates that the player had after closing the application. So I can't influence the movement in any way ?
Юрий Лавринов
@yuralavrinov:matrix.org
[m]

I did something like this, but it's not right @ExtendWith(RunWithFX.class)
public class MazeTests {

@BeforeAll
public static void init() {
    GameApplication.launch(MazeRunnerMain.class, new String[0]);

}

@Test
public void playerInit() {
    assertEquals(40, getGameWorld().getSingleton(PLAYER).getX());
    assertEquals(40, getGameWorld().getSingleton(PLAYER).getY());
    playerComponent.moveRight();
    assertEquals(44, player.getX());

}

}

blueskyonmars
@blueskyonmars
I see that the physics engine is implemented by Box2d. But when I search the example code the physics engine isn't really used for motion, just for collisions. Is the physics engine mostly for platformer games? I was going to create a space-type game with gravity, is it recommended for games to implement their own movement if it is simple enough?