pixi.js

How can I scale the size of a sprite in Phaser/PixiJS without changing its position?

筅森魡賤 提交于 2019-12-22 03:17:06
问题 I'm making a game in Phaser using some large images that I want to scale down in the actual game: create() { //Create the sprite group and scale it down to 30% this.pieces = this.add.group(undefined, "pieces", true); this.pieces.scale.x = 0.3; this.pieces.scale.y = 0.3; //Add the players to the middle of the stage and add them to the 'pieces' group var middle = new Phaser.Point( game.stage.width/2, game.stage.height/2); var player_two = this.add.sprite(middle.x - 50, middle.y, 'image1',

PixiJS demos appear blank in WebView on Android emulator

自古美人都是妖i 提交于 2019-12-13 21:16:33
问题 PixiJS demos such as http://pixijs.io/examples/?v=v4.7.0#/basics/basic.js don't load when rendered in a WebView. Steps to reproduce Android Studio: 3.0.1 Android Emulator: 27.1.12-4623001 Emulator: A "Nexus 5" running API 25 Steps to reproduce Create a new app in Android Studio with a basic activity File > New > New Project On "Create Android Project" screen, click Next On "Target Android Devices" screen, click Next On "Add an Activity to Mobile" screen, click "Empty Activity" and then click

Bind context on vue js method with PIXI JS

孤街浪徒 提交于 2019-12-13 06:16:17
问题 Is it possible to bind context on method? I made an pixi graphic: var square = new PIXI.Graphics(); Then I call my method this.onDragMove and bind square . square .on('pointermove', this.onDragMove.bind(square)); But when I log this it still logs the vue component. onDragMove() { console.log(this); console.log('Object is moving') }, Am I doing something wrong or is it just not possible? 回答1: According to the docs: All methods will have their this context automatically bound to the Vue

Draw a line with gradient in canvas

帅比萌擦擦* 提交于 2019-12-12 16:36:14
问题 I hope this post is not duplicated. I would like to draw a line, as the image shown, that may have different line width and with gradient. I tried createLinearGradient but it is not as what I expected. Shall I use an image instead? Or how can I render the line above? I may work with PixiJS. Update: I can now generate the line with gradient color but how can I create a dynamic width ones? $(function() { var canvas = document.getElementById("canvas"), ctx = canvas.getContext("2d"), painting =

Approach to modifying mutable objects?

旧时模样 提交于 2019-12-11 12:47:15
问题 Given that functional programming is best when sticking to immutable variables as much as possible, and that Ramda always makes shallow copies, how are objects that must be mutable dealt with in a mostly-purely functional framework? For example, consider PIXI.Sprite (in pixi.js). The display system has an inherent hierarchy that is linked together and has its own way of tracking objects so it can re-use textures, etc. Garbage collecting them could be a real problem. What sort of approaches

Scroll / Zoom a pixi.js canvas

泪湿孤枕 提交于 2019-12-06 14:38:02
问题 Below is an easy way to put some text on a pixi.js (using WebGL) canvas. How can we scroll / zoom the displayed part of the canvas ? (i.e. mouse down + drag should move ...) Example of what I would like to achieve : http://s419743653.onlinehome.fr/things/test2.htm <!DOCTYPE HTML> <html> <head> <title>pixi.js example 1</title> <script src="pixi.js"></script> </head> <body> <script> var stage = new PIXI.Stage(0xFFFFFF); var renderer = PIXI.autoDetectRenderer(800, 600); document.body.appendChild

How to add inertia to animations tracking mouse move?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 00:11:58
问题 I'm trying to rotate a triangle around an origin point using mouseMove event. I'm getting the touch start point and the current touch point using touchstart and touchmove events, then I'm finding the angle of direction easily using: alpha = y2 - y1 / x2 - x1; // alpha is the tangent of the angle beta= atan(alpha); // beta is the angle in radians Then I'm rotating the element in PIXI : function animTriangle (beta) { // initially clear the previous shape myTriangle.clear(); // draw a new shape

Custom font in Pixi.js

家住魔仙堡 提交于 2019-12-05 15:04:37
问题 I try to load a custom font into Pixi.js (2D WebGL framework). They have an example using .woff google fonts: https://github.com/GoodBoyDigital/pixi.js/tree/master/examples/example%2010%20-%20Text I converted my .ttf to .woff and added in css: @font-face { font-family: "HU_Adrien"; src: local('HU_Adrien'), url('HU_A0046.woff') format('woff');; } div.font{ font-family: "HU_Adrien"; color: white; } It shows in my div but not in my Pixi stage. ... // create a text object with a nice stroke var

How can I scale the size of a sprite in Phaser/PixiJS without changing its position?

安稳与你 提交于 2019-12-05 00:23:06
I'm making a game in Phaser using some large images that I want to scale down in the actual game: create() { //Create the sprite group and scale it down to 30% this.pieces = this.add.group(undefined, "pieces", true); this.pieces.scale.x = 0.3; this.pieces.scale.y = 0.3; //Add the players to the middle of the stage and add them to the 'pieces' group var middle = new Phaser.Point( game.stage.width/2, game.stage.height/2); var player_two = this.add.sprite(middle.x - 50, middle.y, 'image1', undefined, this.pieces); var player_one = this.add.sprite(middle.x, middle.y-50, 'image2', undefined, this

XDomainRequest vs XMLHTTPRequest

对着背影说爱祢 提交于 2019-12-04 17:02:28
问题 We are creating an application using PixiJS which has a dynamic json loader in it. It loads the .json files using the following: if(window.XDomainRequest) { this.ajaxRequest = new window.XDomainRequest(); } else if (window.XMLHttpRequest) { this.ajaxRequest = new window.XMLHttpRequest(); } else { this.ajaxRequest = new window.ActiveXObject('Microsoft.XMLHTTP'); } Which seems to work everywhere except on windows phone and IE. However, if I swap XMLHttpRequest with XDomainRequest it works fine.