Search the Community
Showing results for tags 'positioning'.
-
I’m trying to make a game with a rocket ship navigating in a cave. The cave is broken up into 400x400 big tiles that’s combined to form a bigger cave. They all have physics-maps from “PhysicsEditor” that seems to work correctly. My tileclass: export default class Tile extends Phaser.Physics.Matter.Sprite { constructor(scene, x, y, sprite, phymap) { super(scene.matter.world, x, y, sprite, 0, { shape: phymap }); this.setStatic(true); this.setBounce(0.05); scene.add.existing(this); } } And these are added in game.js: tilemap[1][0] = new Tile(this, 0, 0, 'ground', tile_body.ground) tilemap[0][0] = new Tile(this, -400, 0, 'bottom-left', tile_body.bottom_left) tilemap[0][1] = new Tile(this, -400, -400, 'vertical', tile_body.vertical) But the tiles are all over the place, if I set them all on position (0, 0) you can see it more clearly: Any ideas to what I am doing wrong? I thought all would be on top of each other if created at position (0, 0) with the same height and width?
-
Hello everyone, I am trying to make the screen scale automatically based on the browser window. So I used the scale variable in world to scale it. I was trying to center it so I used the following code: this.world.x = Math.floor((this.game.width - Global.SCALE * Global.WIDTH) / 2); this.world.y = Math.floor((this.game.height - Global.SCALE * Global.HEIGHT) / 2); which didn't work nothing on the screen moved, I tried world.position.x/world.position.y and world.left/world.top and still nothing changed. Any help?
-
I want a help with a small problem. The problem is How I can load a 3d model into a babylonjs scene. for example: I use blender to open a 3d air conditioner model and then export to babylonjs. Now I have the model as points. I want to load them into a babylonjs scene. I want to be able to position them according to another object in the scene, (for example, a wall). Is there any guidelines? any references? If it is a complicated problem, please guide me to the path I have to follow to solve this problem. Thanks in advance
-
Hi, I need help in the following problem: I am working on a GIS solution and my objective is to create an automation system that accepts an array of coordinates (lat\lng) and outputs a maquette. i.e; I am adding a virtual 3d dimension to the array of points (lat\lng). The problem is when plotting the geographic coordinates array, the result looks like a one point because it's geographic and the distance on earth is very small. What I want is a way to plot the geographic coordinates on the world space but outputs a real corresponding 3d geometry. here is the array of lats-lngs: [50.030462313669034, 26.467167212377877], [50.03022756277145, 26.467086619328583], [50.03012167613479, 26.467340955119003], [50.03035641750763, 26.46742153925565], [50.030462313669034, 26.467167212377877] Note that the difference between the first X and the second X is very small that equals => 0.00023 that when plotting it on BABYLON space looks if the first and second point are the same. I have tried a lot of mathematical normalization ways, to fix this but in vain. "my only condition is to preserve the ratio of objects positions". If any mate can help or suggests a solution. I would be very grateful. Thanks in advance.
-
Hello! This is no insurmountable problem on my end, but I am implementing Babylon as a lightbox with no iframe. In other words, my canvas has its CSS position property set to "fixed". This breaks the placement of the loading screen. Obviously I will patch it up on my end for now, but to make it work out of box, you could replace line 137 in https://github.com/BabylonJS/Babylon.js/blob/preview/src/Loading/babylon.loadingScreen.ts with something like: var canvasPositioning = window.getComputedStyle(this._renderingCanvas).position; this._loadingDiv.style.position = (canvasPositioning == "fixed") ? "fixed" : "absolute"; I'm pretty sure that would have it working out of box in my case.
-
So, making a card game. Im trying to spread the cards in the players hand out, essentially along an upside down, elongated U pattern (basically, the reverse of how you would hold playing cards in real life. - But reverse or not, the task is pretty much the same, fanning the cards and rotating, evenly distributing amongst a finite amount of space. - originally I tried solving it via a super janky function. Then I realized: if I draw the shape I am trying to align the objects around, in theory I could get the coordinates of various points of the shape and then essentially assign each card in hand the distributed coordinates. - So I guess I'm wondering, is there an easy way to do this? I've finally set up a playground to replicate the basic structure of my scene. Sidenote: I am trying to replicate as close as I can to what I actually have, because what I actually have is less than ideal (im having various issues with text rendering, positioning, and other things, that I think may be a scene structure type of issue. (So if you see something stupid that I am doing or that could be improved I'm all ears.) - Anyways here's scene 1, with what I am currently doing with the hand (the rotation is causing the middle cards to appear higher than the cards on the ends, which is the opposite of what I want). https://playground.babylonjs.com/#ZDWG7D#8 Instead I would rather align the bottoms of the cards to the bottom of the half ovalish shape seen here (the player hand shape object) https://playground.babylonjs.com/#H1D1PB But I have been struggling to figure out how to do so. Is there a technique to do this easily? Or anyone have any suggestions? Any help much appreciated as always. P.S. I read https://doc.babylonjs.com/overviews/how_rotations_and_translations_work which sounded like it might lead me to what I am trying to do, but it's still a little advanced for me, and ultimately, the starting point would be knowing how to split up the path of the oval shape into positions, which I am failing to figure out. (and IDK if there is a built in, easier way to align the planes to the bottom of the oval).
-
Hi! With this code I try to put a text object in the center of a sprite, which is in its turn is centered relatively to the world. var sprite = game.add.sprite(0, 0, 'phaser'); sprite.anchor.set(0.5); sprite.x = game.world.width * 0.5; sprite.y = game.world.height * 0.5; var text = game.make.text(sprite.width * 0.5, sprite.height * 0.5, "Yo", { font: "10px Arial", fill: "#ffffff", align: "center" }); text.anchor.set(0.5); sprite.addChild(text); But what I get is this: instead of this: What am I doing wrong and how to achive my goal? Thanks!
-
Hello, I'm experiencing weird behavior positioning a PIXI.mesh.Rope object using Canvas renderer (PIXI v.3.0.10). I put the rope object in a new container and position the container to a fixed point. Now, whenever I change the Pixel ratio (chrome dev tools) and reload the game, the Rope object inside the container moves around to a different location. The position of both the container and the rope object are still the same (debugged it), but visually the rope object inside the container is not in the same place. Secondly, applying width and height to the rope object will not change anything using Canvas renderer. can anyone please confirm that they have the same issues, or maybe suggest something that could cause this behavior. again, all of this does not occur using WebGL renderer thanks.
- 8 replies
-
- positioning
- canvas
-
(and 2 more)
Tagged with:
-
Hey all, I'm looking for some direction on snapping objects into position against other objects edges. I'm also looking to define a snap point on an object and use that to lock it into another objects corresponding point. The first problem is essentially voxel drawing with irregular sized objects (all prisms), I need to be able to click on a face and have the new object placed in relation to the face that I clicked. So if I cast a ray and it finds the top face of an object, the new objects bottom face should align with it. (and snap to whichever side edge the mouse was closer to?) I imagine the second problem as having a little sphere attached to the objects mesh in an arbitrary location, and using that spheres center point to snap into the nearest objects corresponding anchor point. Like defining a hook on an object and using it to snap onto a clothesline. The Babylon.js API is pretty huge and I'm not at all familiar with it, but I have a reasonable grasp of the concepts involved. Any direction or suggestions on how to make a system as I described work would be greatly appreciated.