EzDevInfo.com

stage.js

2D HTML5 JavaScript library for cross-platform game development Stage.js - 2D HTML5 JavaScript Game Engine 2d html5 javascript library for cross-platform game development, it is lightweight, fast and open-source.

When to use actors in libgdx? What are cons and pros?

I'm writing simple solar system simulator. This is my first libgdx project. I'm using a Stage and Actors for the main menu and is pretty handy especially touch events handling. But ... looking at the examples i see nobody uses actors in actual game logic. I wander if i should use actor as a parent of planet class or just write my own class tor that. The planets won't be touchable and they will be moved only between the frames so the third parameter of action MoveBy will have to be time between frames. That are the cons. What are the pros for using Actors?


Source: (StackOverflow)

How to set a JavaFX Stage/Frame to Maximized

I'm using JavaFX 2. I want my frame to open maximized but I'm not seeing a way. I searched a bit on the internet without success. For the stage I see setFullScreen() and setIconified() but I don't see anything like setMaximized().


Source: (StackOverflow)

Advertisements

Center location of stage

I am creating an application in JavaFx, In which I want to do that if any child stage is getting opened then it should be opened in center of parent stage. I am trying to do this using mystage.centerOnScreen() but it'll assign the child stage to center of screen, not the center of parent stage. How can I assign the child stage to center of parent stage?

private void show(Stage parentStage) {
    mystage.initOwner(parentStage);
    mystage.initModality(Modality.WINDOW_MODAL);
    mystage.centerOnScreen();
    mystage.initStyle(StageStyle.UTILITY);
    mystage.show();
 }

Source: (StackOverflow)

JavaFX: How to get stage from controller during initialization?

I want to handle stage events (i.e. hiding) from my controller class. So all I have to do is to add a listener via

((Stage)myPane.getScene().getWindow()).setOn*whatIwant*(...);

but the problem is that initialization starts right after

Parent root = FXMLLoader.load(getClass().getResource("MyGui.fxml"));

and before

Scene scene = new Scene(root);
stage.setScene(scene);

thus .getScene() returns null.

The only workaround I found by myself is to add a listener to myPane.sceneProperty(), and when it becomes not null I get scene, add to it's .windowProperty() my !goddamn! listener handling which I finally retrieve stage. And it all ends with setting desired listeners to stage events. I think there are too many listeners. Is it the only way to solve my problem?


Source: (StackOverflow)

shaking Stage in javaFX

is it possible to shake primary stage with Timeline and so Use XTimeline and YTimeLine?

    final Timeline Xtimeline = new Timeline();//for Animate On X'-Stage
    Xtimeline.setCycleCount(Timeline.INDEFINITE);
    Xtimeline.setAutoReverse(true);
    final Timeline Ytimeline = new Timeline();//for Animate On Y'-Stage
    Ytimeline.setCycleCount(Timeline.INDEFINITE);
    Ytimeline.setAutoReverse(true);

Source: (StackOverflow)

Subversion: stage files to commit explicitly?

I got very used to git's way of having to touch every file you want to commit, and, while at it, double-check the diff. Now at work i have to use svn and i keep commiting stuff accidentially. Is there a way to make subversion behave like git in that i have to tell every file explicitly that should be included in the next commit?


Source: (StackOverflow)

JavaFX Application Icon

Is it possible to change the application icon using JavaFX, or does it have to be done using Swing?


Source: (StackOverflow)

How to implement Minimap of KineticJS Layer?

I am currently working on an application which displays kind of amap. You can do several actions on the map. The map can get really big so the user needs a smaller map (Minimap) to keep track of the whole map.

Currently there are two stages. The one for the big map, one for the minimap. The big map contains several layers, but only one of them needs to be displayed on the minimap (its like a layout).

So I thought about adding an EventListener for AfterDrawing of the specific layer.

this.layoutLayer.afterDraw(this._initMinimap);

In the Event Listener I am doing the following:

//...
_initMinimap : function(event) {
    var ctrl = event;
    if (!this.minimap) {
        this.minimap = new Kinetic.Stage({
            container : 'container',
            width : 165,
            height : 165
        });
    }
    if (!this.mapLayer) {
        this.mapLayer = new Kinetic.Layer({});
    }
    this.mapLayer.clear();
    this.minimap.clear();
    this.layoutLayer.toImage({
        callback : function(img) {
            var image = new Kinetic.Image({
                image : img
            });
            image.setScale(0.01,0.01);
            ctrl.mapLayer.add(image);
        }
    });
    this.minimap.add(this.mapLayer);
    this.minimap.draw();
},
//...

Does anyone has an idea of how to solve this issue? I am not that familiar with JavaScript yet so I am not quite sure if this is the right approach.

Thanks in advance :-)


Source: (StackOverflow)

Set Height and Width of Stage and Scene in javafx

  • I develop one javafx application.
  • In my application there are two scenes and one stage.
  • In application the height and width for both scenes are same or constant.
  • so as per my research the height and width for scene remain constant which mention in the constructor but the scene adjust itself with height and width of stage.
  • when i lunch application with the height and width of stage which is different than the constant height and width of scene then scene adjust with stage.
  • but when at the run time when i apply the 2nd scene then scene is not adjust with height and width of stage.the height and width of scene remain constant.

  • so any solution?


Source: (StackOverflow)

Why is stage undefined in my Actionscript 3 class even though I've imported the Stage class?

 package    {

 import flash.display.Stage;

 public class MyGlobal {

  public static  var CX:Number = stage.stageWidth / 2;
  public static  var CY:Number = stage.stageHeight / 2;  

 }

}

The Error is "1120: Access of undefined property stage." WHY?


Source: (StackOverflow)

Git porcelain command to revert a single file to its HEAD state but keep its staged state?

Is there a git porcelain command to revert the working dir state of a staged file to its HEAD state and at the same time keep the staged state of the file? Later I would like to be able to revert the working dir state to the staged state of the file. My initial thought was to use git checkout HEAD -- targetfile, but it resets the staged state of the file too. I see that this is doable with git stash, but it affects other files while I would like to focus on a single file and preserve the state of the others untouched as otherwise it could lead to merge conflicts:

git add targetfile
git stash
... // modify tagetfile in seeking of different task solution, possibly modifying other files too
git checkout HEAD -- targetfile //drop the different solution attempt, keep other modified files if any
git stash apply --index // revert to the stashed staged solution, but produces merge conflict for other modified files

I found a nice article with summary table at the end which lacks the scenario described in this question. In my opinion this should be easily feasible, but I am surprised that staged and working dir states are so tightly coupled - you can reset the staged state for a file while preserving its working dir state, but I have hard time to achieve the opposite.


Source: (StackOverflow)

Kineticjs how to centre image on stage and resize depending on browser

I am adding an image to the stage as a background image and a rectangle. How can I ensure that the rectangle is centred on the stage and that the background resizes depending on the browser?

<body style="overflow: hidden">
<div id="container" style="width:100%;height:100%;margin:auto;"></div>
<script>
var stage = new Kinetic.Stage({
container: 'container',
width: 1680,
height: 1050
});

var layer = new Kinetic.Layer();
stage.add(layer);

var rect = new Kinetic.Rect({
    x: 239,
    y: 75,
    width: stage.getWidth() / 2,
    height: stage.getHeight() / 2,
    fill: 'green',
    stroke: 'black',
    strokeWidth: 4
  });

  layer.add(rect);
  stage.add(layer);

var imageObj = new Image();
  imageObj.onload = function() {
    var myBg = new Kinetic.Image({
     x: 0,
      y: 0,
      image: imageObj,
      width: 1770,
      height: 1200,
      opacity: 0
    });

    layer.add(myBg);
    stage.add(layer);    

imageObj.src = 'img/bg.png';
  </script>
 </body>

Source: (StackOverflow)

ImageButton doesn't seem to detect clicks (Scene2d.ui)

When trying to put a simple ImageButton on stage, It didn't seem to detect clicks.

ImageButton btnStart = new ImageButton(ButtonArt.UP, ButtonArt.DOWN));

// btnStart.setClickListener(new ClickListener() {
//          @Override
//          public void click(Actor a, float arg1, float arg2) {
//             a.visible = false;
//          }
//       });

stage.addActor(btnStart);

ButtonArt.UP and ButtonArt.DOWN are TextureRegions, of each state. Now when I click on the button, it doesn't change state! I also tried the above ClickListener (for testing), but it seemed that didn't work either.

In my render method I just call stage.act() and stage.render(). I also tried drawing the TextureRegions with SpriteBatch in my render method, and they are in fact different textures.

Am I doing something wrong?


Source: (StackOverflow)

How to stage a Maven release without creating scm tag?

Our current SDLC goes something like this:

  1. Develop code & unit tests
  2. Release to QA for system testing
  3. Repeat steps 1 & 2 as required until QA is passed
  4. Promote to UAT
  5. Repeat steps 1 to 5 as required until UAT is passed
  6. Deploy to production

We are using the maven-release-plugin to manage the releases, but want to maintain the same build number throughout the cycle. Currently each time we build, the artifact release version increases. e.g. 1.2.3 released to QA, fix errors and rebuild becomes 1.2.4, etc.

We have looked at using the release:stage goal, however the first use creates a tag in SCM, and each subsequent use of release:stage builds from this SCM tag, and does not include any code added after this tag is created. We've tried using release:rollback after release:stage to remove the scm tag, but this does not work.

Is there a way to perform this type of release cycle?

Thanks.


Source: (StackOverflow)

how can one detect a finished resizing operation in JavaFX?

I have a stage, a scene and a WebView node. When I expand the window to a larger size - things get pretty sluggish due to WebView. What I want to do is fill the new space for WebView only when the resizing of the window has been finished (this is me releasing left mouse button on the resizable control/edge of the window). For now I can just set the max. size of this node to what it is by default - this will stop it from expansion. But how can I detect the actual event of a completed resizing operation on the window? With binding, I can verify that the resizing takes place - but it's instantaneous (properties for W & D change immediately w/o releasing LMB), while I only require an action when the LMB has been released. Suggestions?


I tried using an addEventFilter on the stage for Event.ANY, just to see if this event type is recognizable - sadly with no avail.

I've also stumbled upon this unanswered post.


Source: (StackOverflow)