Tag Info

New answers tagged

1

Use the overload of the drawImage method of 2DContext that allows you to draw part of an image. MDN calls it slicing: drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight) Given an image, this function takes the area of the source image specified by the rectangle whose top-left corner is (sx, sy) and whose width and height are sWidth and ...


1

Your issue comes from the fact that your 'hex' canvas is hidden by your 'ground' canvas, and do not receive the mouse events. But in fact you don't care from which canvas the click event was raised : just have your mouse handling code hook the events of the top-most canvas, and use those coordinates. (I assume here that all canvases have the same size ...


0

found answer: #canvas_ground { left: 201px; pointer-events: none; <<--------- this helps position: absolute; top: 31px; z-index: 1; }


0

Try to remake your game in libgdx. Libgdx is fast enough and doesnt have issues like that and it works on all platforms. Unfortunately this is only what I can think of right now and I dont like the idea of converting js to android java or whatever that coverter does. Although it will take some time, give LibGDX a test.


0

Saw this the other day, might well be worth a look to solve this problem. Sounds like a pretty nice idea to me: http://tmtg.net/glesjs/ The fact that it works fine when in browser, but not when on Phonegap/Cordova is very strange indeed. The whole canvas/webGL situation on Android (can't speak for iOS) has always seemed pretty dire to me. Definitely ...


0

This issue is almost certainly codec / sound format related, but without knowing how your bgm.mp3 file is encoded it's really hard to tell. Maybe the encoding bitrate is too high, or the device can't handle mp3 files and needs ogg instead? You'll have to experiment I'm afraid as it's hard to say exactly from the post.


2

Phaser has support for two types of sprite sheet: "classic" ones, where every frame is the exact same size, and "texture atlases" which are created with the help of a third party app like Texture Packer, Shoebox or Flash CC and come with an associated json file. You load the "classic" ones with game.load.spritesheet where you must specify the width and ...


1

var sprite = game.add.sprite(x, y, 'spritesheet_name'); sprite.frame = 0; Spritesheets aren't limited to animations, that's just one way to use them. An animation is just a way to display different frames at different times. By manually setting the frame of a sprite, you can display a specific part of the spritesheet.


1

I've been targeting node-webkit for my html5/js game. Most of my code runs browser-side, so the node.js aspects are mostly because its simple enough to have it run a small server and send down the html/js code to the embedded browser. A good demo of a fast-paced game is, "A Wizard's Lizard". They talk about their success on reddit, and they apparently use ...


0

You can accomplish this with CanvasRenderingContext2D's methods setTransform, save, and restore. Together they allow you to create a draw transform stack, which permits you to draw all your tiles at their (unchanging) world position, but have them move around on screen. If you have a position of the left-top world-position of your viewport, you can create ...


0

If I understand the question correctly, you want a camera that you can move, which is not a standard with vanilla canvas. To emulate this, you should create two variables for the x and y position of the camera. You can then manipulate these values for instance if you want the camera to move when the player moves. To make all your scenes objects act properly ...


1

If you'd like your game board to appear sharp, with lines of 1px width, at different resolutions, then you may be better off drawing your game board in the SVG vector format, using a tool like Inkscape or Illustrator. SVG files do have a nominal pixel resolution, as defined by the viewBox attribute of the SVG tag. This makes calculation of the positions of ...



Top 50 recent answers are included