Code Monkey home page Code Monkey logo

adapt-game-frame's Introduction

adapt-game-frame

Game Frame is a presentation component for the Adapt framework.

sample game iframe component

Game Frame is based on the Responsive Iframe plugin and is built to allow you to embed responsive HTML5 games from tools like PhaserJS into your course and block the course from continuing until the game is complete.

Visit the Game Frame wiki for more information about its functionality and for explanations of key properties.

##Installation

With the Adapt CLI installed, run the following from the command line:
adapt install adapt-game-frame

Alternatively, this component can also be installed by adding the following line of code to the *adapt.json* file:  
`"adapt-game-frame": "*"`  
Then running the command:  
`adapt install`  
(This second method will reinstall all plug-ins listed in *adapt.json*.)  

Settings Overview

The attributes listed below are used in components.json to configure Game Frame, and are properly formatted as JSON in example.json.

Attributes

core model attributes: These are inherited by every Adapt component. Read more.

_component (string): This value must be: game-frame.

_classes (string): CSS class name to be applied to Game Frame’s containing div. The class must be predefined in one of the Less files. Separate multiple classes with a space.

_layout (string): This defines the horizontal position of the component in the block. Acceptable values are full.

instruction (string): This optional text appears above the component. It is frequently used to guide the learner’s interaction with the component.

_source (string): The source of the game's index.html (e.g. course/en/game/index.html)

_loadingImg (string): The source of an image that can show to prevent an empty black square when the user hasn't clicked on the game.

_originURL (string): This is the URL of the adapt course. This allows the game to pass a message to the course using the postMessage API, e.g. http://localhost:9001 This message is used to trigger the setCompletionStatus for the component and block.

Usage

This plugin uses the postMessage API to pass a message back to the Adapt course. Within the components.json, you must change the _originURL to match the origin URL of the Adapt course.

Inside of your game, you must include a postMessage call with the same origin URL, for example:

window.top.postMessage("The game is complete", "http://knanthony.com");

where the first argument is the message to pass and the second argument is the target origin. The target origin must match the origin URL of the Adapt course.

Limitations

Phaser JS scale manager is not working appropriately on iOS devices. So, this plugin includes an object tag which performs responsively on iOS devices. To use the object tag instead of the iframe, you must comment out the iframe tag in the game-frame.hbs (handlebars template) and uncomment the object tag version.

<div class="component-inner gameIframe-inner">
  {{> component this}}
  <div class="component-widget gameIframe-widget">
    <div class="gameIframe-iframe-holder">
      <img src="{{_loadingImg}}" />
      <!-- <iframe scrolling="{{#if _scrolling}}{{_scrolling}}{{else}}no{{/if}}" class="gameIframe-iframe" src="">
      </iframe> -->
      <object type="text/html" data="" class="gameIframe-object"></object>
    </div>
  </div>
</div>

You must also comment out the iframe-specific command in the once method and uncomment the object-specific command:

once: function(fired) {
          if (!fired) {
            this.$('.gameIframe-object').attr('data', this.model.get('_source'));
            // this.$('.gameIframe-iframe').attr('src', this.model.get('_source'));
          } else {
            return;
          }
        },

The message is still passed appropriately to the Adapt course.


Version number: 1.1.0 Framework versions: 2.0
Author / maintainer: Kristin Anthony
Accessibility support: Unknown
RTL support: no
Cross-platform coverage: Latest Chrome, Firefox, Safari, iOS Chrome

adapt-game-frame's People

Contributors

anthkris avatar letithappen avatar simondate avatar

Stargazers

 avatar

Watchers

 avatar  avatar

adapt-game-frame's Issues

Component doesn't allow multiple instances on the same page

Don't know if there is some other reason for not allowing multiple instances of the adapt-game-frame component.
Using a component attribute _IsFired with "fired = this.model.get('_isFired')" before https://github.com/anthkris/adapt-game-frame/blob/master/js/adapt-game-frame.js#L49 and setting it to true inside or after the "once" function would allow to separate the component behavior between instances allowing the use of multiple instances with different src or data.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.