Search the Community

Showing results for tags 'canvas'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Coding and Game Design
  • Frameworks
    • Phaser
    • Pixi.js
    • Babylon.js
    • Panda.js
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Found 292 results

  1. 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!
  2. Greeble, a #js13k entry

    Hello everyone! Last week I finished my #js13k entry, Greeble. I'd love it if you guys could give it a play and let me know what you think.
  3. Pixi.js Showcase

    Made anything cool with pixi.js? Post it up here and share it with the world! Whether it's a cool game demo, a fully fledged website or some tripped-out crazy experiment, we would all LOVE to see it! To get the ball rolling, here are some pixi.js projects that exist out on the internets: games: experiments:
  4. Pixi.JS / Pan & Zoom Canvas

    Hi, I'm using Pixi since several days on a game prototype which consists in a map made of tiles. The problem is that I got a big map (2000px / 2000px), so it don't fit a desktop screen, and not any mobile screen. I am looking for a way to allow the user to pan (i.e. navigating on the canvas with mouse drag and drops (for desktop) and with the finger (for mobile devices) zoom in / out the canvas Like in google maps for example Any idea of an embedded feature I can use? Thanks in advance for you answers.
  5. Game with AJAX->PHP

    I'm new to game development. I want to create a game that is decided on the server side with PHP. The graphics will be shown using Canvas and I would hope that some graphics would be used from Illustrator. I need to know if the pixi.js framework can be used to communicate via AJAX to represent different graphics through user interaction. Example. User makes a decision -> values are calculated on the server side -> sent back and represented with graphics. Is this possible? I took a glimpse at the documentation and searched for AJAX but found nothing.
  6. Hi there, everytime I have to make a game that pauses when the canvas loses the focus (jquery blur()) I struggle with lines and lines of stupid lines of javascript and I´m pretty sure there´s something simpler than my way to do that. I have a normal sprite on the game that pauses/unpauses the game, and I would like to do exactly the same when the canvas focus/blur... how do you guys handle this?
  7. Less lag in video panning - is my code so far I am wondering is there a way that would cause less lag when the mouse moves left, right, up, down, etc . Also is there a where that when the mouse goes out side of the canvas to keep on panning to show the whole video
  8. Hi everybody: I need to know about what is the preferred approach to handle the mouse/touch events (for example onclick): (1) via the canvas by means of myCanvas.addEventListener("pointerdown", function (evt) { ... var pickInfo=myScene.pick(myScene.pointerX,myScene.pointerY,function(mesh){ return (mesh===myMesh); }); if(pickInfo.hit){ alert("Mesh picked"); } }); (2) via the mesh using the powerful ActionManager functionality myMesh.actionManager.registerAction(new BABYLON.ExecuteCodeAction(BABYLON.ActionManager.OnPickDownTrigger,function(evt){ alert("Mesh picked"); })); Thank you for your time.
  9. Player and Colliding Objects

    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() {, -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; } // 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;'left'); } // player presses right key else if (cursors.right.isDown) { player.body.velocity.x = 100;'right'); } // player presses up key else if (cursors.up.isDown) { player.body.velocity.y = -100;'up'); } // player presses down key else if (cursors.down.isDown) { player.body.velocity.y = 100;'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="" 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>
  10. On mobile, when you want to scroll the page, you drag screen with one finger. However, when your finger is on canvas, you can't drag the page. If a canvas covers whole screen, there is no way to scroll the page. Is there a way to enable scrolling-dragging if canvas element is under the finger?
  11. Welcome to the Pixi.js forum

    Hi everyone and welcome to the PIXI.js forum! First off, big thanks to @photonstorm for providing a place for people to talk Pixi, very kind of you sir! If you dont know what pixi.js is then let me give ya the low down: Pixi.js a fast, lightweight, open source 2D library that works across all devices. The Pixi renderer allows everyone to enjoy the power of hardware acceleration without prior knowledge of webGL. It's the fastest HTML5 renderer in town! The idea behind pixi.js is that it can be used as the rendering component in your game engine (or any other type of project!) rather than as a game engine itself. Questions / bug reports / amazing feature ideas, or anything at all Pixi, then this is the place to discuss it! I will also be posting updates here as the engine grows and evolves. Pixi.js can be found here along with lots of examples: To find out more about Pixi and read our beginners tutorial, check out our blog over on Goodboy
  12. Hi, On Firefox the camera stops rotating when your pointer leaves the canvas: Which doesn't happen on Edge, IE, Chrome or Opera
  13. When Canvas better WebGL

    Hi, On some Android devices canvas renderer works better and stable than Web GL Some games may crash in Web GL mode when in canvas mode all games stable. I want to ask is there any way how can we detect it ? Maybe some benchmarks exist ?
  14. Hi All, I am a JavaScript developer with more than 7+ years of experience on HTML5 game development, i can work on game development for multiple platforms. I can work on projects with limited timeline and budget, available for both part time and full time. Regards, Gideon
  15. Hello & Thanks , Still looking for *.js library that can be developed/run without 'local web server' . Can Phaser do this ? I read a tutorial that looked like this is possible . Thanks...Vern
  16. Character Customization Idea

    I have this idea for creating a character customization system. The system would be implemented as follows. 1) Organize a base template sprite sheet with character components arranged in a composition for future compositing. Example: Lets assume a full body template for a characters design is 125 by 125 consisting of head, body, and leg components. The head component of the character would use 25 pixels and would be isolated on separate parts of the sprite sheet that occupies the respective pixels while the rest of the 100/125 pixels are blank. The same would be done for the body and leg components. 2) Bind the components together via some sort of linked list or maybe even graph based implementation. I'm still learning about graphs and am thinking they're best for this system given compositing more complex sprite sheets will involve layers. Any advised implementations or any kind of information on graphs associated with player creation systems is highly appreciated. I think this is a great opportunity to practice graphs. 3) Next there will be an interface that allows the player to choose the color and textures of each of these components. The player will confirm and submit their design when finished. Now that the player has submitted their design, I'm a bit puzzled about the next step and have a few ideas on composing the data. 4a) Use Phaser api to turn the data into bitmaps? I don't know much about this implementation yet since I'm still learning how to utilize bitmaps and how Phaser handles bitmaps 4b) Composite the items on a canvas and store it in a uri using the canvas to url method. I also lack experience with api but I definitely can see how it would work. 5) Ideally I'll save the data to a database and retrieve them via player credentials. I'm not sure if I'm over complicating things or not so any feedback would be appreciated. I use Phaser but any html5 based idea or solution should be fine.
  17. Hey, Everyone I'm dying making attempts to scale canvas for high dpi mobiles and get everything work correctly. Problem: When I start Phaser with 100% width/height for canvas it will be created according to css pixel size of device (window.innerWidth/innerHeight). So iPhone 6S for example, gets, 375x667 canvas, but in fact, of course it should be 2x bigger because devicePixelRatio is 2. Result, everything is blurry and not as expected. Ok, I decided to set width and height with devicePixelRatio included and then set CSS size of canvas to 100% of view port. let w = window.innerWidth * window.devicePixelRatio; let h = window.innerHeight * window.devicePixelRatio; let game = new Game(w, h) // And then in style sheet: canvas { width: 100vw !important; height: 100vh !important; } Now, it seems like everything looks perfect and as expected (is it correct way to do it?). But, another problem rises. Seems like after this events.onInputDown do not work correctly. When I click on sprite nothing happens, but in different location click handled. Seems like coordinates of input arena is messed up. Can someone help me this this?
  18. Morning! Just working on a bit of a debug console for my game, was just wondering if it was at all possible to switch the renderers at runtime? Have tried a couple of methods, but it just halts the code from executing I think (no error), but guessing it would be a nogo?
  19. Hey guys, I make games!

    Hey guys, I have a business of fiverr in which I literally make html games in 2 days time. I usually go for around $5-10, and I already have one 5 star review. Check it out:
  20. I'm trying to move a canvas object towards a onmousedown position, which gets sent from a user to the server. But my problem is the following: The object on the canvas is only moving a little step towards the delivered position. There must be a problem which could be caused by the dest calculation. Youtube video which shows my problem: A jsfiddle with a working example: Code which sends the position from the user to the server and which draws each user on the canvas: <script type="text/javascript"> var ctx = document.getElementById("ctx").getContext("2d"); ctx.canvas.width = window.innerWidth; ctx.canvas.height = window.innerHeight - 142; var socket = io(); socket.on('newPositions', function(data) { ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.fillStyle = "rgb(255,0,0)"; ctx.beginPath(); for(var i = 0; i < data.length; i++){ ctx.arc(data[i].x, data[i].y, 10, 0, Math.PI * 2); } ctx.closePath(); ctx.fill(); }); document.onmousedown = function(event) { socket.emit('positionUpdate', {x: event.pageX - ctx.canvas.offsetLeft, y: event.pageY - ctx.canvas.offsetTop, state: true}); } document.onmouseup = function(event) { socket.emit('positionUpdate', {x: event.pageX - ctx.canvas.offsetLeft, y: event.pageY - ctx.canvas.offsetTop, state: false}); } </script> Part of the app.js code which contains the current position update code var serv = require('http').Server(app); var SOCKET_LIST = []; var PLAYER_LIST = []; var Player = function(id, x, y){ var self = { x: 100, y: 100, id: id, number: "" + Math.floor(10 * Math.random()), mouseMovement: false, maxSpd: 5, radius: 10 } self.updatePosition = function(x, y) { if(self.mouseMovement){ // Problem movement var targetX = x; var targetY = y; var tx = targetX - self.x; var ty = targetY - self.y; var dist = Math.sqrt(tx * tx + ty * ty); var velX = (tx / dist) * self.maxSpd; var velY = (ty / dist) * self.maxSpd; if (dist > self.radius / 2) { self.x += velX; self.y += velY; } // Problem movement end } } return self; } var io = require('')(serv, {}); io.sockets.on('connection', function(socket){ console.log('socket connection'); = Math.random(); SOCKET_LIST[] = socket; var player = Player(; PLAYER_LIST[] = player; socket.on('disconnect', function(){ delete SOCKET_LIST[]; delete PLAYER_LIST[]; }); socket.on('positionUpdate', function(data){ player.mouseMovement = data.state; player.updatePosition(data.x, data.y); }); }); setInterval(function(){ var pack = []; for(var i in PLAYER_LIST){ var player = PLAYER_LIST[i]; player.updatePosition(); pack.push({ x:player.x, y:player.y, number:player.number }); } for(var i in SOCKET_LIST){ var socket = SOCKET_LIST[i]; socket.emit('newPositions', pack); } }, 1000/30); Explaination: The following code sends the target position to the server: document.onmousedown = function(event) { socket.emit('positionUpdate', {x: event.pageX - ctx.canvas.offsetLeft, y: event.pageY -ctx.canvas.offsetTop, state: true}); } Then the following code will be triggered: socket.on('positionUpdate', function(data){ player.mouseMovement = data.state; player.updatePosition(data.x, data.y); }); Which will set the player.mouseMovement to true and delivers the targeted x and y cordinates to the player.updatePosition function: self.updatePosition = function(x, y) { if(self.mouseMovement){ // Problem movement var targetX = x; var targetY = y; var tx = targetX - self.x; var ty = targetY - self.y; var dist = Math.sqrt(tx * tx + ty * ty); var velX = (tx / dist) * self.maxSpd; var velY = (ty / dist) * self.maxSpd; if (dist > self.radius / 2) { self.x += velX; self.y += velY; } // Problem movement end } } I would appreciate any kind of help or suggestions.
  21. Hi All, I'm a JavaScript developer with goods hands on experience on game development. I need artists to develop games for IOS ,Android and web. if any one intrested do Pm me.
  22. small games

    Hello, I'm currently making little games on codepen to teach myself how to bluid them and get better at it So i thought it could be nice if I post on this topic every time i make a new game for the feedbacks I'm using javascript and render graphics on canvas, and piskel for the spritesheets. 1/ Marble labyrinth Created JANUARY 23, 2017 tilt the screen with your mouse and move the sphere to the square, beware the holes in the ground. Link: 2/ The Dungeon Created FEBRUARY 07, 2017 walk through the dungeon, each time you enter a new room your score get higher. Link: 3/ Copycat Created MARCH 30, 2017 This game is about cloned cats which you control at the same time Link: 4/ Don't touch the spikes (clone) Created MAY 05, 2017 Link :
  23. Hi, I know this should not be BabylonJS issue, just intend to aware people that Lenovo Phab 2 Pro may have canvas rendering issue. I am using chome to open the webpage, while firefox and opera had no problem displaying the 3D scene. below are screenshots of webpage with webgl content: The Sponza Demo: The Espilit Demo: The Instances Demo: And all ThreeJS projects I had viewed so far have this issue too: Lasertown: The Aviator: It looks like the major area of the canvas is covered, and leaving only a small rectangle area at the left bottom corner to be viewable, I am able to apply user input beyond the viewable rectangle area to navigate the scene(for example the Espilit demo). I had file an bug report to chrome and intend to file another one to lenovo as well.
  24. Hey guys, I'm looking for some advice on canvas scaling. We're working on a PixiJS game and want to have the canvas as big as possible based on a set aspect ratio. I've got it all working fine but when I started testing it on our benchmark devices I noticed the performance has dropped horribly. When I scale the canvas using CSS transform the performance is perfect but then the graphic quality is unacceptable. Does anyone have some advice how to get great scaling on any device (including 4k monitors) while still maintaining performance and good graphic quality? --- Good performance but bad quality scaling method const canvas: HTMLCanvasElement = document.getElementById('game-stage') as HTMLCanvasElement; const width = window.innerWidth; const height = window.innerHeight; const ratio = window.devicePixelRatio * 2; = '0 0'; = `scale(${Math.min(width / Constants.FIELD_SIZE.x, height / Constants.FIELD_SIZE.y)})`;, canvas.height); Good quality scaling but bad performance scaling method const canvas: HTMLCanvasElement = document.getElementById('game-stage') as HTMLCanvasElement; const width = window.innerWidth; const height = window.innerHeight; const ratio = window.devicePixelRatio * 2; canvas.width = width * ratio; canvas.height = height * ratio; = width + 'px'; = height + 'px'; if (height / Constants.FIELD_SIZE.y < width / Constants.FIELD_SIZE.x) { this.scene.scale.x = this.scene.scale.y = height / Constants.FIELD_SIZE.y * ratio; } else { this.scene.scale.x = this.scene.scale.y = width / Constants.FIELD_SIZE.x * ratio; }, canvas.height);