Skip to content

Commit

Permalink
Merge branch 'master' of git@github.com:away3d/gloop-a-hoop.git
Browse files Browse the repository at this point in the history
Conflicts:
	development/flash/lib-swc/preload.swf
  • Loading branch information
rob-bateman committed May 15, 2012
2 parents 39796ba + 7dbfc21 commit 517a893
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 5 deletions.
Binary file added development/flash/lib-swc/preload.swc
Binary file not shown.
Binary file modified development/flash/lib-swc/preload.swf
Binary file not shown.
2 changes: 1 addition & 1 deletion development/flash/src/Wrapper.as
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ package {
[Embed(source="../lib-swc/preload.swf", symbol="LoadingScreenAsset")]
private var LoadingScreenAsset:Class;

[Embed(source="../assets/images/Title Loading Bar Screen.png")]
[Embed(source="/../assets/images/Title Loading Bar Screen.png")]
private var LoadBarBitmap:Class;

private var _loader:Loader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ package com.away3d.gloop.gameobjects {
_width = width;
_physics = new GoalWallPhysicsComponent(this, offsetX, offsetY, width, height);
_physics.enableReportBeginContact();
_physics.enableReportEndContact();
super(offsetX, offsetY, width, height, worldX, worldY);

initVisual();
Expand Down Expand Up @@ -64,8 +65,9 @@ package com.away3d.gloop.gameobjects {
_splatDistance = 1;
}

override public function onCollidingWithGloopStart( gloop:Gloop, event:ContactEvent = null ):void {
super.onCollidingWithGloopStart(gloop);
override public function onCollidingWithGloopEnd( gloop:Gloop, event:ContactEvent = null ):void {

super.onCollidingWithGloopEnd(gloop);

var gloopCenter:V2 = gloop.physics.b2body.GetWorldCenter();
var wallCenter:V2 = this.physics.b2body.GetWorldCenter();
Expand Down
40 changes: 38 additions & 2 deletions development/flash/src/com/away3d/gloop/input/MouseManager.as
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.away3d.gloop.input

import away3d.containers.View3D;

import com.away3d.gloop.utils.PlatformUtil;

import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
Expand All @@ -20,6 +22,8 @@ package com.away3d.gloop.input

protected var _view:View3D;
protected var _mouseDown:Boolean = false;
private var _mouseIsOut:Boolean;
private var _needMouseLeaveHack:Boolean;

public const PLANE_POSITION:Vector3D = new Vector3D( 0, 0, 0 );

Expand All @@ -29,18 +33,34 @@ package com.away3d.gloop.input
_planeD = -_planeNormal.dotProduct( PLANE_POSITION );
_intersection = new Vector3D();
_intersectionPoint = new Point();

// need mouse leave hack?
if( !PlatformUtil.isRunningOnMobile() ) {
if( PlatformUtil.isRunningOnSafari() ) {
_needMouseLeaveHack = true;
}
}

}

public function activate():void {
_view.addEventListener( MouseEvent.MOUSE_DOWN, onViewMouseDown );
_view.stage.addEventListener( MouseEvent.MOUSE_UP, onViewMouseUp );
_view.addEventListener( Event.MOUSE_LEAVE, onViewMouseUp );

if( _needMouseLeaveHack ) {
_view.stage.addEventListener( MouseEvent.MOUSE_MOVE, updateMouseLeave );
}
_view.stage.addEventListener( Event.MOUSE_LEAVE, onViewMouseUp );
}

public function deactivate():void {
_view.removeEventListener( MouseEvent.MOUSE_DOWN, onViewMouseDown );
_view.stage.removeEventListener( MouseEvent.MOUSE_UP, onViewMouseUp );
_view.removeEventListener( Event.MOUSE_LEAVE, onViewMouseUp );

if( _needMouseLeaveHack ) {
_view.stage.addEventListener( MouseEvent.MOUSE_MOVE, updateMouseLeave );
}
_view.stage.addEventListener( Event.MOUSE_LEAVE, onViewMouseUp );
}

public function update():void {
Expand Down Expand Up @@ -80,5 +100,21 @@ package com.away3d.gloop.input
public function get projectedMousePosition():Point {
return _intersectionPoint;
}

public function updateMouseLeave( event:Event ):void {
if( _view.stage.mouseX < 0 ||
_view.stage.mouseX > _view.stage.stageWidth ||
_view.stage.mouseY < 0 ||
_view.stage.mouseY > _view.stage.stageHeight ) {
if( !_mouseIsOut ) {
_mouseIsOut = true;
_view.stage.dispatchEvent( new Event( Event.MOUSE_LEAVE ) );
}
}
else if( _mouseIsOut ) {
_mouseIsOut = false;
_view.stage.dispatchEvent( new Event( "mouseEnter" ) );
}
}
}
}
41 changes: 41 additions & 0 deletions development/flash/src/com/away3d/gloop/utils/PlatformUtil.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.away3d.gloop.utils
{
import flash.external.ExternalInterface;
import flash.system.Capabilities;

public class PlatformUtil
{
public static function isRunningOnMobile():Boolean {
var playerType:String = Capabilities.playerType;
return playerType != "DirectX" && playerType != "PlugIn";
}

public static function isRunningOnSafari():Boolean {
var browser:String = checkBrowser();
return browser == "Safari";
}

public static function checkBrowser():String {
var browser:String;
var strUserAgent:String = String( ExternalInterface.call( "function() {return navigator.userAgent;}" ) ).toLowerCase();
if( strUserAgent.indexOf( "firefox" ) != -1 ) {
browser = "Firefox";
}
else if( strUserAgent.indexOf( "msie" ) != -1 ) {
browser = "Internet Explorer";
}
else if( strUserAgent.indexOf( "safari" ) != -1 ) {
browser = "Safari";
}
else if( strUserAgent.indexOf( "chrome" ) != -1 ) {
browser = "Google Chrome";
}
else if( strUserAgent.indexOf( "opera" ) != -1 ) {
browser = "Opera";
} else {
browser = "none";
}
return browser
}
}
}

0 comments on commit 517a893

Please sign in to comment.