Search the Community
Showing results for tags 'CSS'.
-
Why is the following CSS code not centering my button horizontally within a div element? It appears off-center in my webpage: <!DOCTYPE html> <html> <head> <style> .container { width: 100%; display: flex; justify-content: center; align-items: center; } .btn { background-color: #3498db; color: white; padding: 10px 20px; border: none; border-radius: 5px; } </style> </head> <body> <div class="container"> <button class="btn">Click Me</button> </div> </body> </html> The button seems to be slightly towards the left side within the container. What am I missing in the CSS that is preventing the button from being perfectly centered?
-
Hi All, I Hope I've put this in the right place, I've been struggling with this issue for a while now. I've had a stack overflow issue open for more than a year and no replies. In basics. I overlay a canvas on my UI DOM, this canvas has animations / particles / tutorial pointers etc. to make the UI prettier and filled with motion. The problem comes when you try to scroll something that is underneath this canvas, the scrolling becomes disproportionate Please see my stackoverflow issues: https://stackoverflow.com/questions/67511840/disproportional-overflow-scrolling-on-scaled-element https://stackoverflow.com/questions/67541498/disproportionate-scrolling-on-element-with-an-overlaying-pointer-eventsnone-el Has anyone battle with this before? Or perhaps any suggestions for a workaround? Kind Regards, SanCoca
-
noticing lately that certain .png assets for my game are appearing somewhat blurry in google chrome. i think it began in chrome version 93. what i'm doing now is downgrading to version 92 in order to test play, but every time chrome opens it wants to automatically upgrade to a newer version (ver 93 or 94 as of this posting). my index.html uses some image sharpening css, which i suspect may have something to do with it. they look something like this: <style> * { cursor: none; cursor: url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7), auto; image-rendering: crisp-edges; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: optimize-contrast; image-rendering: -webkit-optimize-contrast; image-rendering: optimizeSpeed; image-rendering: pixelated; -ms-interpolation-mode: nearest-neighbor; margin: 0; transform: translateZ(0); } </style> any advice on how to unblur things would be appreciated. i'm sure it has nothing to do with any new lines i've added, because i haven't added any, and am also test playing a version of my game which looked sharp in ver 92 and older.
-
I tried to change image quality in image-rendering css, but whenever i change the value it seems always pixelated. Because my image is not pixel art, i want the value of image-rendering to optimizeQuality or auto. So can melonjs achieve that? here is my css : image-rendering: optimizeQuality; image-rendering: -moz-crisp-edges; image-rendering: -o-crisp-edges; image-rendering: -webkit-optimize-contrast; image-rendering: opti mize-contrast; -ms-interpolation-mode: bicubic;
-
This may turn out to be more of a CSS question than a Phaser question, but what is the magic formula for making the Phaser canvas exactly fill the browser viewport without any scrollbars? I have tried using window.innerWidth and window.innerHeight and that almost works, but the canvas seems to turn out a little too big and gives me a vertical scrollbar. Even with padding: 0 and margin: 0 on everything (html, body, div, canvas) I end up with a few pixels worth of scroll. The same thing seems to happen in both Firefox and Chrome. Any suggestions?
-
Hi, I am trying to format a specific part of a Phaser.Text object as a superscript. I am using TypeScript in the project. For example: var question: Phaser.Text = this.add.text(0, 0, "3x2", { font: "24px Arial", fill: "#000", align: "center" });Looks like: 3x2 But I want it to look like: 3x2 Unfortunately String.prototype.sup() is depreciated. How would I get this result? I know I can use the <sup> tag, but am not sure how to use this in a Phaser.Text object. Thank you.
- 5 replies
-
- superscript
- subscript
-
(and 6 more)
Tagged with:
-
Check here ! Well, not actually the first game, but first which I’m finally done and self-publish. The game is pretty simple: just repeat numeric sequence. That easy! Nothing should be difficult ))) It works on top of HTML5 technologies. Powered by preact and by pure css effects. The intend was to learn react hooks and dive deeply into css. After a while react was replaced by more lighter and faster - preact. As you can see, those are not quite usually used for game dev., but I was motivated So, please, give me your thoughts about this one. Check here !
-
Hi, I'm tinkering with a strategy game concept and I thought I could try web-based technologies for faster prototyping. I'm more of a Java programmer, so I'm learning the ropes, but I think that a web game will be easier to iterate on with over people : no need to install anything, just go to the link! I saw there are multiple frameworks: pixi, phaser, melon, babylon, etc. All of these have some basic support for UI, but it looks to me it still is pretty poor compared to DOM/CSS native features, or you need a greater involvement in graphics wrt code. Following a few tutorials, I could easily use Vue+Bulma to draw a quick UI prototype (see https://guillaume-alvarez.github.io/technologies-app/), only missing the game map (that will need another framework obviously), I think it would have taken me much much longer to do the same thing with Pixi (I tried it a few years back). However I see most game only UI is made in the same framework as the main game view (pixi, phaser, etc.)... So I'm curious... Why is that? Maybe my use case is a bit specific, relying more on UI than on animations? Or I missed some great UI library for these frameworks? Or for mobile screens you need a more integrated UI? What am I missing?
-
What I want to do is make it so if the player touches the enemy from the side then the player either loses a life and or it causes the game to be over. But if the player jumps on top of the enemy then it causes that enemy to disappear. If a the player touches an enemy then the player loses a life which is done by running this code... this.status = "lost"; this.finishDelay = 1; How ever if the player jumps on the enemy then the enemy dies which is done by running this code... this.actors = this.actors.filter(function(other) { return other != actor; }); Here is my code so far... Level.prototype.playerTouched = function(type, actor) { } else if (type == "lava" && this.status == null && player.y == enemy.y) { this.status = "lost"; this.finishDelay = 1; } else if (type == "coin" && player.y > enemy.y) { this.actors = this.actors.filter(function(other) { return other != actor; }); } }; The part that I am having trouble with is... when the player touches the enemy while the player is on the ground (the players y axis is equal to the enemys y axis)... player.y == enemy.y and when the player jumps on top of the enemy. (the players y axis is greater then the enemys y axis)... player.y > enemy.y My total code is posted as an attachment platformgame2.html
- 1 reply
-
- javascript
- html5
-
(and 2 more)
Tagged with:
-
Hello, i have got a question. I am created a gui simple button and also i want to take the button properties from CSS file. I tried so many things, but i couldn't reach my aim. I need helps from masters.
-
Well... I want to learn how to make games, for PC, browser or mobile. I started to learn logic then I passed to HTML and CSS, I learned the basics of those two then I started to see the basic of JS. I did a break for a few months to focus on school, but now I'll return my programming studies. And I heard that C# is the best choice for gamedev using the Unity Engine. So, I want to know what is the best choice, stay learning JS or start to learn C#?
-
About MGN Studios: MGN Studios is the new game development division of Freedom! Family Limited. Our mission is to create great games and technologies that actively engage and involve the YouTube community of players, bloggers, reviewers and creators. We’re setting up shop right here in beautiful Vancouver! If you want to join a start-up where you get to work remotely and build something new, and be a part of an honest & transparent leadership team with a veteran Studio Head, then MGN Studios is for you! THE ROLE: Are you up for the challenge? We are currently seeking a Senior Game Engine Developer to join our team in leading the architecture and development of browser-based video game engine technology. You will be the driving force in the design and development of our studio’s game engine infrastructure. You should be comfortable diving deep into technical architectures and requirements, able to quickly identify solutions to challenges discovered during development, and ready to direct and mentor other developers in creating a robust and scalable code base. Prior experience building browser-based multiplayer game technology is preferred. We are looking for someone to be a key participant in the creation of a collaborative environment that leverages agile development and rapid prototyping; rewards creative solutions and intelligent risk taking; fosters a culture of excellence, respect, and fun; and makes great games. RESPONSIBILITIES: Are you ready to make a contribution to our team? Lead the design, implementation, and growth of a browser-based HTML5 multiplayer game engine. Manage and mentor a team of software developers through the interactive development process. Set company-wide code development standards and best practices. Work with game designers and artists in the development of game features, art pipelines, and tools. Partner with producers, PMs, and other leads on schedules and plans. Identify technical and production issues/risks and propose solutions. QUALIFICATIONS: Do you have what it takes? Degree in Computer Science and/or relevant professional experience. 5+ years experience in professional software development. 3+ years of experience in the development of game engines. Very good knowledge of existing game engines (e.g. Unity, GameMaker, Phaser, Pixi, Turbulenz, etc.) and server side technologies. Deep knowledge of modular programming, API design, and game architectural patterns. Extensive experience with frontend and backend technologies such as HTML5, Javascript, CSS/CSS3, jQuery, PHP, Python, Node.js, MySQL, etc. Source revision control experience (Github preferred). Professional experience in agile software development. Experience working effectively in cross-functional game teams. Excellent oral and written English communication skills. Experience developing MMO city builder games is a PLUS Experience developing casual MMO .io games is a PLUS Experience with Apache Ant, iOS WebKit, Android Webkit / Chrome is a PLUS Knowledge of video platforms including YouTube, Dailymotion and Twitch is PLUS COMPENSATION: Competitive Salary Flexible work hours Flexible work locations (home, office, etc.) Are you intrigued? Here are a few more reasons to make MGN Studios your daytime/anytime home: Work remotely - Did we already mention you get to work remotely? Yes, it’s true! Leadership - Do you like working with veteran Studio Head who will give you clear direction, honesty and guidance, and believes people are the pillars to success. He’s the opposite of an evil villian with a curly moustache. Build something new - Play a role in building a game development studio that can’t stop and won’t stop growing. Career growth - Make an impact by leading projects and driving the direction of the studio. Develop initiatives and solutions that drive your career and boost the studio’s growth. For Freedom! Does this sound like you? Please apply asap as we are interviewing immediately for this permanent, full time position. PM and we can arrange a time to speak over the phone!
-
Since Phaser is a web framework, we the developers, have a choice between drawing GUI (Menus, inventory screens, buttons etc) on the canvas or use built in browser elements with all the functionality and response and just connecting it to the game engine. What would you recommend? Drawing and handling clicks on canvas is a little harder, but if there are any sound benefits to that I would love to know. Thanks
-
Hi all, I was trying to optimize our mobile experience, so instead of including a big background image in on of my texture sheets, I've made it into a simple .jpg image and set that as a CSS background with the following properties : body { margin: 0; padding: 0; background: url('assets/images/bg.jpg') no-repeat center center fixed; background-position: 50% 100%; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; height: 100%; overflow: hidden; } On iOS and desktop Chrome + Safari, the behaviour is as expected, but on Android Chrome, it seems to affect my Canvas size, as if the canvas was bigger than the whole screen. The weird thing is as I hit refresh multiple times, the behaviour changes from having correct canvas size to incorrect. If there is no way around that, I'm just going to go back to my background being part of my texture atlases. Thanks for any input! Edit: after playing around a bit with how I create Phaser's game object, I just realized that Android does not treat screen density like iOS does (ie. Retina vs xhdpi etc), so I basically added code so that on Android width and height are "100%" with a scale mode of RESIZE, and on iOS width and height are window.innerWidth * window.devicePixelRatio with a scale mode of SHOW_ALL and everything seems to behave correctly now. Let me know if you see any issues with my approach, thanks!
-
- background
- phaser
-
(and 1 more)
Tagged with:
-
Hey everyone! I wanted to get a bit of help getting a function working whereby when I hover my mouse over character sprites it will show a there name and title just above the mouse position for each different sprite, I'm unsure if I need to look at going down the route of a mouse hover/mouse over function or i need to create an event listener. If anyone could make a demo that I could play with and learn from or something that would be perfect! Thanks guys! Mezz
-
Hi All! Do you have experience in HTML Game Developement? And the following skill set? JavaScript, JQuery HTML/HTML5 CSS/CSS3 Pixi JS / Spine JS Google Closure Active knowledge of English Send me a PM if you would like to know more details about this. Relocation is required and VISA is supported. Please don't contact me if you are selling services from company's. Only looking for people who are willing to move to Prague and have a full time contract with us.
-
Hey Guys! I have a question! I wanted to know if there is a way that when you click on a sprite can you set the css value for display to none for all other sprites - so essentially, when one sprite is clicked(chosen) all others display:none the chosen is set to display:block. I'm going for the effect of click on one character and it hides the others so you see your selected character and there bio(name, description etc...) appears next to them as display: block whereas all others are display: none. I am struggling as I can't call the sprite elements within the canvas by flat css - so was wandering if and how it is possible to achieve my hoped functionality! This might be something for you @Wingnut? Thankss! Mezz out!
- 5 replies
-
- css
- javascript
-
(and 1 more)
Tagged with:
-
Hi, I need some help with my code, I am trying to create a fenced in area for my character to go in, but he cannot fit through because of the objects that he collides with. How do I change the area that the character collides with? can I reduce the size of the collidable area? The hole in the fence seems quite large enough, but he just won't go through. My game.js // variables for items, walls, etc. var walls; var house; var game = new Phaser.Game(550, 540, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); //add house to game function addHouse(image) { house = game.add.physicsGroup(); house.create(-250, -240, 'greenhouse'); house.setAll('body.immovable', true); } // add fences/walls to the game function addWalls(image) { walls = game.add.physicsGroup(); // fences up top walls.create(-90, -200, 'fencefront'); walls.create(5, -200, 'fencefront'); walls.create(100, -200, 'fencefront'); walls.create(195, -200, 'fencefront'); // fences to right walls.create(288, -200, 'fenceright'); walls.create(288, -135, 'fenceright'); walls.create(288, -70, 'fenceright'); walls.create(288, -5, 'fenceright'); // fences at bottom walls.create(-90, 59, 'fencefront'); walls.create(5, 59, 'fencefront'); walls.create(100, 59, 'fencefront'); walls.create(195, 59, 'fencefront'); // fences to left walls.create(-91, -200, 'fenceright'); walls.create(-91, -135, 'fenceright'); walls.create(-91, -70, 'fenceright'); // set the walls to be static walls.setAll('body.immovable', true); } // preload items, walls, players, etc. function preload() { // preload player game.load.spritesheet('player', 'hero.png', 64, 64); // preload houses game.load.image('greenhouse', 'greenhouse.png'); // preload fences game.load.image('fencefront', 'fencefront.png'); game.load.image('fenceleft', 'fenceleft.png'); game.load.image('fenceright', 'fenceright.png'); } // variables for character var cursors; var player; var left; var right; var up; var down; // add what will be in game function create() { game.world.setBounds(-250, -250, 550, 550); // set background color game.stage.backgroundColor = ('#3c6f42'); // add player image and place in screen player = game.add.sprite(-232, -100, 'player', 1); player.smoothed = false; player.scale.set(1); // player will "collide" with certain images like walls and houses player.collideWorldBounds = true; // ANIMATION FOR PLAYER CONTROLS down = player.animations.add('down', [0,1,2,3], 10, true); left = player.animations.add('left', [4,5,6,7], 10, true); right = player.animations.add('right', [8,9,10,11], 10, true); up = player.animations.add('up', [12,13,14,15], 10, true); // enable physics in the game (can't go through walls, gravity, etc.) game.physics.enable(player, Phaser.Physics.ARCADE); game.physics.startSystem(Phaser.Physics.P2JS); game.physics.p2.enable(player); // make sure to add this code to add items/walls/buildings addHouse(); addWalls(); // enable keyboard arrows for controls cursors = game.input.keyboard.createCursorKeys(); // camera will follow the character game.camera.follow(player); } // what happens when player does something function update() { // player will now collide with these images rather than pass over them game.physics.arcade.collide(player, house); game.physics.arcade.collide(player, walls); // PLAYER CONTROLS player.body.velocity.set(0); // player presses left key if (cursors.left.isDown) { player.body.velocity.x = -100; player.play('left'); } // player presses right key else if (cursors.right.isDown) { player.body.velocity.x = 100; player.play('right'); } // player presses up key else if (cursors.up.isDown) { player.body.velocity.y = -100; player.play('up'); } // player presses down key else if (cursors.down.isDown) { player.body.velocity.y = 100; player.play('down'); } // player does not press anything else { player.animations.stop(); } } function render() { } The HTML <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Simple Canvas Game</title> <link href="https://fonts.googleapis.com/css?family=Syncopate:700" rel="stylesheet"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> html { background: black } canvas { margin: auto; } h1 { font-family: 'Syncopate', sans-serif; color: rgb(194, 68, 91); text-align: center; margin: 0 auto; font-size: 25px; } </style> </head> <body> <header> <h1>Crafty Heroes</h1> </header> <script src="phaser.js"></script> <script src="game.js"></script> </body> </html>
-
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.
-
Hey guys, I have made some scaling of the game via CSS so I can have my game always the proper size in the browser window. However, I lose my onInputDown because for some reason the game container overflows but visually is okay.... here is my CSS styling (visually it looks perfect): html { height: 100%; margin: 0; padding: 0; } body { height: 100%; margin: 0; padding: 0; } #content { height: 100%; } #content > canvas { margin: 0 auto; height: auto !important; width: auto !important; max-height: 100%; max-width: 100%; position: relative; top: 50%; transform: translateY(-50%); } Here is my game init class: import Boot from 'states/Boot'; import Preload from 'states/Preload'; import GameState from 'states/GameState'; import * as Constants from 'data/Constants.js' class Game extends Phaser.Game { constructor() { let height = window.screen.height; let width = window.screen.height / Constants.SIXTEEN_TO_NINE; super(width, height, Phaser.AUTO, 'content', null); this.state.add('Boot', Boot, false); this.state.add('Boot', Preload, false); this.state.add('GameState', GameState, false); this.state.start('Boot'); }; } new Game(); If I don't have any css code - the input works. I believe it is because the game is still bigger than what it visually appears. Has anyone had this issue?
-
So to get right to the point. I am having issues with my ship image/sprite and my drawn objects on screen disappearing as soon as I try and addEventListener to code. why does my code essentially break when i add the EventListener? is it not possible to add controls to image or sprite within Html canvas? Ship game code = https://codepen.io/BlaineP16/pen/VpQBZV
- 2 replies
-
- html
- javascript
-
(and 1 more)
Tagged with:
-
So i am trying to orbit a small sphere around a bigger sphere like so: var orbit = new Sprite(loader.resources.RedB.texture); stage.addChild(orbit); orbit.anchor.set(0.1, 0.1); orbit.position.x= Gball.x*1.3; orbit.position.y = Gball.y/3; orbit.scale.set(0.15, 0.15); Gball.addChild(orbit); animate(); function animate() { requestAnimationFrame(animate); // just for fun, let's rotate mr Honeypot a little Gball.rotation -= 0.05; // render the container renderer.render(stage); } now the only problem is that when i click on the button to remove the child, but want him to keep the position he had in the animation: var ballX = orbit.x; var ballY = orbit.y; document.getElementById("bot").addEventListener("click", function () { var orbit = new Sprite(loader.resources.RedB.texture); stage.addChild(orbit); orbit.anchor.set(0.1, 0.1); orbit.position.x= ballX; orbit.position.y = ballY; orbit.scale.set(0.15, 0.15); Gball.removeChild(orbit); return false; }); does anyone know how i might be able to do that?
-
Hi everyone! Just wanted to share a small proof-of-concept game I've been working on for a while. It's called The monster's vault. The main goal is to find a way out of a dark creepy dungeon, pull a lever that opens the exit door, while not being caught by a wandering monster that dwells in the darkness, and bla-bla-bla... the whole point here is not about gameplay anyway. This game is inspired by Keith Clark's demo of an HL2 location made entirely by CSS 3d transforms. I tried to repeat his approach by making a browser 3d game with first-person view based on CSS transforms without any use of canvas graphics. My other goal was to try out a number of modern web technologies and APIs available in the browser, so here's what I came out with. ReactJS as a rendering framework and Redux as a game state manager. Kind of a questionable choice for a game, one may think, but hey, as I said, it's a proof-of-concept WIP demo pet home project =) Pointer lock events to control the cursor so that it cannot flow out of the screen. Gamepad api to support my Xbox One gamepad. I haven't been more happy when it actually worked (not sure about other controllers though). Web audio api to control the sounds and the music. It provides a way to place a sound in a 3d space and even make it spread in a certain direction, and that's really awesome. Using your headphones while playing is highly recommended. Service worker makes the game work offline as it caches all the resources after the first load. It can get annoying though, when you start facing the problems with invalidating the cache. I also tried out the svg lighting filters to simulate some shaders on the textures (set on highest graphics quality value in the Settings section). It looks neat but drops the fps dramatically. Some conclusions: declarative 3d graphics with CSS 3d transforms and animations are cool and relatively easy to use, but not performant enough (which is totally fine) modern browsers have some really great APIs helpful for creating various web games making horror games is a huge, huge fun PLEASE NOTE: The monster's vault is only a desktop game and is viewed best in latest Google Chrome. It is inconceivably untested and may not work as expected on most machines and browsers. Some of the technologies used here are still not standardized and may break in the future. Also, the code is not optimised in any way, it weights some MBs. The low rendering FPS is compensated by the high cooler's RPS =) Anyway, I warned you. The game's github repo with some gifs, controls and credits — https://github.com/alvov/the-monsters-vault-game. You can play the game here: https://alvov.github.io/the-monsters-vault-game. Thanks!
-
I am a recent (about 4 months) user of Phaser, and have successfully built 4 games, not too complex. I have been struggling with putting up geometrical objects without making an image and loading that. The easiest way (that I know) to dynamically create the geometries I want (eg, rounded rectangle with dashed border) is a div with CSS styling specifying the border and position. This works from inside the javascript code fine, but then I cannot specify the Z-plane (to make it appear at all I need to do position:absolute and then it is always on top, and buttons beneath it do not get touch/click events) and I cannot enable drag. Is there a good solution for this within a Phaser game? If I can get this mix of CSS styling and sprites to work, there are a lot of things I could do with them. The attempt: objBack = document.createElement("div"); objBack.setAttribute("id", "objectBackground"); var xoff = WIDTH/2-obhalfx var yoff = HEIGHT-butLoc objBack.setAttribute("style", "position:absolute;float:center;left:"+xoff+"px;top:"+yoff+"px;color=#77ccff;width:800px;height:200px;border-radius: 5px 5px 5px 5px;-moz-border-radius: 5px 5px 5px 5px;-webkit-border-radius: 5px 5px 5px 5px;border: 2px dashed #8a888a;") var gameDiv = document.getElementById("game"); gameDiv.appendChild(objBack);