Skip to content

Commit

Permalink
Remove matter.js from dxopal.js
Browse files Browse the repository at this point in the history
  • Loading branch information
yhara committed Jan 27, 2018
1 parent dc985c3 commit 294c1e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,20 @@
## (not yet)

### Breaking change: matter.js is split from dxopal.js

To use `DXOpal::Sprite::Physics`, you need to load matter.js explicitly.

Old:

<script src="dxopal.min.js"></script>

New:

<script src="matter.js"></script>
<script src="dxopal.min.js"></script>

### Other improvements:

- new: Image#set_color_key
- new: Window.draw_scale
- new: Show the message of an exception if there is a `<div id='dxopal-errors'>`
Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Expand Up @@ -13,10 +13,9 @@ file "build/dxopal.min.js" => "build/dxopal.js" do |t|
sh "uglifyjs #{t.source} -o #{t.name}"
end

file "build/dxopal.js" => Dir["opal/**/*.rb"] + ["vendor/matter.js"] do |t|
file "build/dxopal.js" => Dir["opal/**/*.rb"] do |t|
Opal.append_path("opal")
js = Opal::Builder.build("dxopal.rb").to_s
js << File.read("vendor/matter.js")
File.write(t.name, js)
end

Expand Down
1 change: 1 addition & 0 deletions examples/matter/index.html
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset= "utf-8" />
<title>DXOpal demo</title>
<script type="text/javascript" src="../_vendor/matter-0.10.0.js"></script>
<script type="text/javascript" src="../../build/dxopal.js"></script>
<script type="text/ruby">
DXOpal.dump_error{ require_remote 'main.rb' }
Expand Down
5 changes: 2 additions & 3 deletions opal/dxopal/sprite/physics.rb
@@ -1,9 +1,8 @@
module DXOpal
class Sprite
# Experimental Matter.js (physics engine) support
# TODO: Currently matter.js is embeeded in build/dxopal.js (see Rakefile).
# It is better to make it optional (i.e. do not embed matter.js and
# enable Matter.js support when matter.js is loaded before dxopal.js)
#
# You need to load matter.js in advance to using these features.
module Physics
# Create Matter Body and register it to the World
# - type: :rectangle, etc.
Expand Down

0 comments on commit 294c1e4

Please sign in to comment.