File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -340,6 +340,35 @@ Phaser.Utils = {
340340
341341 } ,
342342
343+ /**
344+ * Mixes in an existing mixin object with the target.
345+ * Prototype values with that have either `get` or `set` functions are created as properties via defineProperty.
346+ *
347+ * @method Phaser.Utils.mixinPrototype
348+ * @param {object } target - The target object to receive the new functions.
349+ * @param {object } mixin - The object to copy the functions from.
350+ */
351+ mixinPrototype : function ( target , mixin ) {
352+
353+ var mixinKeys = Object . keys ( mixin ) ;
354+
355+ for ( var i = 0 ; i < mixinKeys . length ; i ++ )
356+ {
357+ var key = mixinKeys [ i ] ;
358+ var value = mixin [ key ] ;
359+
360+ if ( value && ( typeof value . get === 'function' || typeof value . set === 'function' ) )
361+ {
362+ Object . defineProperty ( target , key , value ) ;
363+ }
364+ else
365+ {
366+ target [ key ] = value ;
367+ }
368+ }
369+
370+ } ,
371+
343372 /**
344373 * Mixes the source object into the destination object, returning the newly modified destination object.
345374 * Based on original code by @mudcube
You can’t perform that action at this time.
0 commit comments