All Projects → azerion → phaser-responsive

azerion / phaser-responsive

Licence: MIT license
Adds a set of responsive objects to Phaser that can be pinned to

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to phaser-responsive

phaser-plugin-advanced-timing
Shows FPS, frame intervals, and performance info. Phaser 2/CE
Stars: ✭ 25 (+0%)
Mutual labels:  phaser, phaser-plugin
craft
Phaser Library with utility chainable functions
Stars: ✭ 27 (+8%)
Mutual labels:  phaser, phaser-plugin
phaser-plugin-game-scale
Scale or resize the game canvas. Phaser v3.15 only
Stars: ✭ 35 (+40%)
Mutual labels:  phaser, phaser-plugin
phaser-plugin-scene-graph
Prints the display tree. Phaser 2/CE
Stars: ✭ 32 (+28%)
Mutual labels:  phaser, phaser-plugin
phaser-super-storage
A cross platform storage plugin for Phaser
Stars: ✭ 49 (+96%)
Mutual labels:  phaser, phaser-plugin
phaser-particle-editor-plugin
This plugin creates particles based on JSON data generated by Phaser Particle Editor
Stars: ✭ 28 (+12%)
Mutual labels:  phaser, phaser-plugin
phaser-nineslice
NineSlice plugin for Phaser!
Stars: ✭ 52 (+108%)
Mutual labels:  phaser, phaser-plugin
phaser-ui-comps
Phaser 3 UI Components built by Adobe Animate
Stars: ✭ 60 (+140%)
Mutual labels:  phaser, phaser-plugin
phaser-plugin-debug-arcade-physics
Draws properties of Arcade Physics bodies. Phaser 2/CE
Stars: ✭ 18 (-28%)
Mutual labels:  phaser, phaser-plugin
ts-phaser-bomb-game
Bomberman clone using websockets and phaser 3
Stars: ✭ 18 (-28%)
Mutual labels:  phaser
phaser-candy-crush
Candy crush like game made with Phaser HTML5 game engine
Stars: ✭ 46 (+84%)
Mutual labels:  phaser
TooManyCaptains
🕹 Too Many Captains and Not Enough Wire
Stars: ✭ 34 (+36%)
Mutual labels:  phaser
phaser-jam-template
A Phaser Template to kick off your Game Jam with everything you need. Typescript, code quality, building for itch, various input methods, examples, bootloader, preloader, main game, end screen, credits screen and license screen.
Stars: ✭ 18 (-28%)
Mutual labels:  phaser
node-vue-phaser-boilerplate
Boilerplate to get started developing Node.js-server + Vue/Phaser-client online-games, based on Webpack and with Babel/ES2015 support.
Stars: ✭ 25 (+0%)
Mutual labels:  phaser
blocker
🎮 (WIP - phase 3) Multiplayer online game using Phaser + WebSocket (Socket.IO)
Stars: ✭ 48 (+92%)
Mutual labels:  phaser
phaser-mario
Mario-like class for Phaser
Stars: ✭ 19 (-24%)
Mutual labels:  phaser
mmo-arch
Base Architecture for creating scalable games using microservices through Angular, Phaser, NestJS, NATS, and MySQL
Stars: ✭ 25 (+0%)
Mutual labels:  phaser
Flappy-Bird
🐦 A Simple 2D Game Using Phaser
Stars: ✭ 13 (-48%)
Mutual labels:  phaser
chunks tutorial
Small demo showing how to load and manage tilemap chunks on the fly with Phaser 3
Stars: ✭ 41 (+64%)
Mutual labels:  phaser
phaser multiplayer demo
HTML5 Multiplayer with Phaser and Go
Stars: ✭ 35 (+40%)
Mutual labels:  phaser

Phaser Responsive

Phaser-Responsive plugin adds images/sprites/buttons/groups that can be pinned to corners/sides/center!

NOTICE

This repo is depecrated in favor of Phasers alignIn / alignTo methods introduced in [email protected]

Getting Started

First you want to get a fresh copy of the plugin. You can get it from this repo or from npm, ain't that handy.

npm install phaser-responsive --save-dev

Next up you'd want to add it to your list of js sources you load into your game

<script src="node_modules/phaser-responsive/build/phaser-responsive.js"></script>

Usage

Load the plugin

You still need to load the plugin in your game. This is done just like any other plugin in Phaser

game.plugins.add(Fabrique.Plugins.Responsiveness);

The plugin will patch your Phaser game with additional load/add/make methods so the responsive objects fits up in Phaser like any normal object!

Create responsive objects

Add an image, text, button or sprite as you would in Phaser, adding 'responsive' in front of the name. When creating them, add a pin position in the parameters which can be either the middle of the canvas or one of it's edges.

The available pin positions are:

  • topLeft
  • topCenter
  • topRight
  • middleLeft
  • middleCenter
  • middleRight
  • bottomLeft
  • bottomCenter
  • bottomRight

Then, set an anchor point to align the corner of the image/text/button/sprite with the corner of the canvas.

sampleImage = game.add.responsiveImage(5, 5, 'square', null, Fabrique.PinnedPosition.bottomRight);
sampleImage.anchor.set(1, 1);
spriteButton = game.add.responsiveButton(5,5, 'leaderboard', this.myCallBack,this,0,0,0,0, Fabrique.PinnedPosition.bottomRight);
spriteButton.anchor.setTo(1,1);

Set scaling for objects

By setting the landscape/portrait scaling for an object, the object will be scaled a certain percentage of the width or height of the total game. By default the width will be used, if you want the object to scale according to the height, you can pass the second parameter as false. The scaling will only be done on mobile, if you want the objects to be scaled when your game is running on desktop you can pass the third parameter as true.

In the next example the sampleImage will always be 50% of the game width in landscape and 50% of the game height in portrait.

sampleImage = game.add.responsiveImage(5, 5, 'square', null, Fabrique.PinnedPosition.bottomRight);
sampleImage.setLandscapeScaling(50, true, false);
sampleImage.setPortraitScaling(50, false, false);

Relative pinned position

If you want the offset of your objects to be relative to the game size you can also pass a pinned position and an x and y offset to the landscape/portrait scaling.

In the next example the sampleImage will always be 20% of the game width and be positioned to the middle left. When the image is the original size the offset will be 100px, when the image is scale the 100px will be relative to the scaling.

sampleImage = game.add.responsiveImage(5, 5, 'square', null);
sampleImage.setLandscapeScaling(20, true, false, Fabrique.PinnedPosition.middleLeft, 100, 0);
sampleImage.setPortraitScaling(20, true, false, Fabrique.PinnedPosition.middleLeft, 100, 0);

Changelog

1.3.0

  • Pinned position offset is now relative to portrait/landscape scaling

1.2.0

  • Objects can now store their portrait/landscape special scaling values

1.1.0

  • Added static dynamic scaling method

1.0.1

  • Initial release

Disclaimer

We at OrangeGames just love playing and creating awesome games. We aren't affiliated with Phaser.io. We just needed some awesome objects that needed to be responsive in our awesome HTML5 games. Feel free to use it for enhancing your own awesome games!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].