Skip to content

Check out some of our latest work

2011 March 31
by admin
Master of Mot

Master of Mot

Petra's Planet

Petra's Planet

Demolition Dude

Demolition Dude ( > 7 million plays)



Snailer

Ragdoll Goalkeeper ( > 6 million plays)

Flailery RPG (Android w/ AIR)



Touchscreen D-pad with AIR for Android (part 1 of 2)

2011 October 4
by admin

A lot of games use the directional pad or arrow keys for movement. When you move to mobile devices with only a touchscreen, you lose one of the staples of your game controls. I’ll show a simple way of getting your D-pad back and hopefully allowing you to make the transition to mobile easier.

We need to listen to the TOUCH_BEGIN, TOUCH_MOVE and TOUCH_END events. If you’re familiar with mouse events already, you can think of BEGIN as MOUSE_DOWN and END as MOUSE_UP. The biggest difference between a mouse and touch screen is that there can be multiple touches so you need to keep track of which is which. If you got three fingers on the screen and only follow the events, it’s gonna be a mess.

How to keep track of the touches then? Each touch has touchPointID associated with it so whenever a touch event is fired, you can dig it up and compare it with all your known touch IDs. For now we will use the first touch to occur and assign that for our D-pad.

Before anything else, let’s set the input mode for the Multitouch class to Touch_Point. This means Flash will only track the basic touch events like when the touch begins, when it moves and when it ends.

1
2
3
private function init():void{
  Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
}
private function init():void{
  Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
}

Then add some basic listeners for Touch events.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// ... extends Sprite
 
private var dpadTouchID:int=-1;
 
public function init():void{
  Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
 
  addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
  addEventListener(TouchEvent.TOUCH_END, touchEnd);
}
 
private function touchBegin(e:TouchEvent):void{
  dpadTouchID = e.touchPointID;
}
 
private function touchEnd(e:TouchEvent):void{
  dpadTouchID = -1;
}
// ... extends Sprite

private var dpadTouchID:int=-1;

public function init():void{
  Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

  addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
  addEventListener(TouchEvent.TOUCH_END, touchEnd);
}

private function touchBegin(e:TouchEvent):void{
  dpadTouchID = e.touchPointID;
}

private function touchEnd(e:TouchEvent):void{
  dpadTouchID = -1;
}

Something I’ve noticed is that touchPointID’s always start from 0 and go up. We’ll use -1 to tell when there is no touch assigned to the D-Pad.

We shouldn’t assume that there’s only gonna be one touch because there probably will be atleast 2. We’ll add some checks to make sure we’re only looking at the correct touch and add a event listener for TOUCH_MOVE so we can track the movement of the finger.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// ... extends Sprite
 
private var dpadTouchID:int=-1;
 
public function init():void{
  addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
  addEventListener(TouchEvent.TOUCH_END, touchEnd);
  addEventListener(TouchEvent.TOUCH_MOVE, touchMove);
}
 
private function touchBegin(e:TouchEvent):void{
  if(dpadTouchID == -1){
    dpadTouchID = e.touchPointID;
  }
}
 
private function touchEnd(e:TouchEvent):void{
  if(e.touchPointID == dpadTouchID){
    dpadTouchID = -1;
  }
}
 
private function touchMove(e:TouchEvent):void{
//make sure a D-Pad touch is assigned at all, and then check if it matches
  if(dpadTouchID != -1){
    if(e.touchPointID == dpadTouchID){
      // success! let's print out the x and y!
      trace('D-Pad is moving!', e.stageX, e.stageY);
    }
  }
 
}
// ... extends Sprite

private var dpadTouchID:int=-1;

public function init():void{
  addEventListener(TouchEvent.TOUCH_BEGIN, touchBegin);
  addEventListener(TouchEvent.TOUCH_END, touchEnd);
  addEventListener(TouchEvent.TOUCH_MOVE, touchMove);
}

private function touchBegin(e:TouchEvent):void{
  if(dpadTouchID == -1){
    dpadTouchID = e.touchPointID;
  }
}

private function touchEnd(e:TouchEvent):void{
  if(e.touchPointID == dpadTouchID){
    dpadTouchID = -1;
  }
}

private function touchMove(e:TouchEvent):void{
//make sure a D-Pad touch is assigned at all, and then check if it matches
  if(dpadTouchID != -1){
    if(e.touchPointID == dpadTouchID){
      // success! let's print out the x and y!
      trace('D-Pad is moving!', e.stageX, e.stageY);
    }
  }

}

The red area shows where the touch area is for the finger, right now its overlapping right and up arrows.

Ok, now we’re tracking the D-pad touch around. It’s still pretty much acting like a mouse though. We want to use the touch tracking for a D-pad so we’ll need to figure out based on those X and Y coordinates if the finger is on top of any of the D-Pad buttons. Just for examples sake, we’ll draw a simple graphic to represent the four directional buttons. The buttons are 100×100 pixels in size. The touch area we’ll be using is going to be 60 pixels so it’s small enough to still be precise but big enough so that it can cover two buttons at a time. This way you get 8 directions easily.

Right now we’re using the 60×60 square for the finger area but TouchEvent’s have some interesting properties you might want to look into later. For example; pressure, sizeX and sizeY. Those should come in handy when creating more sophisticated controls.

Next create some simple graphics for the buttons. We’ll name them upArrow, downArrow, leftArrow and rightArrow. They should be a descendant of the DisplayObject class for this.

You want to re-check which buttons your finger is touching whenever it has moved and when it’s first pressed into the screen. So we should modify touchMove(e) and touchBegin(e) to check that.

Stay tuned for part 2!

Master Of MOT

2011 September 9
by admin

We developed a new physics based game with Redland Oy for Kielikone to promote their new mobile dictionaries. In the game you throw the MOT character from your phone and try to hit the right object. The object you’re supposed to hit is shown to you in one of the languages found in the dictionary.

PLAY IT HERE!

Ragdoll Hockey Goalie

2011 May 17
by admin

I just released a new game called Ragdoll Hockey Goalie! It’s a remake of the football version but you play as an ice hockey goalie and can choose your team. Go Finland!

It was immediately chosen as the game of the week(?) on pelikone.fi.
Play it here!

Some Flex components that might be useful, Indexed RadioButton Group, Flex MovieClip

2011 March 12
by admin

In my last project I made some possibly useful Flex classes that I’ll briefly explain and share here. Maybe I should set up a GitHub with them soon or something.

The first one is IndexedRadioButtonGroup which improves the spark(Flex4) RadioButtonGroup by adding methods that help you keep track and control the index of which radio button is selected. The main use for this is using radio buttons for navigation.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// IndexedRadioButtonGroup.as
package com.designoidgames.ui
{
    import flash.events.Event;
    import flash.utils.getTimer;
 
    import mx.core.IFlexDisplayObject;
 
    import spark.components.RadioButtonGroup;
 
    public class IndexedRadioButtonGroup extends RadioButtonGroup
    {
 
        public function IndexedRadioButtonGroup(document:IFlexDisplayObject=null)
        {
            super(document);
        }
 
        public function getCurrentIndex():int{
            for(var i:int=0;i
<this.numRadioButtons;i++){
                if(getRadioButtonAt(i) == this.selection){
                    return i;
                }
            }
 
            return -1;
        }
 
        public function selectIndex(index:int):void{
            selection = getRadioButtonAt(index);
            dispatchEvent(new Event(Event.CHANGE));
        }
 
        public function moveLeft(ignoreEnabled:Boolean=false):void{
            var index:int = getCurrentIndex();
            index = Math.max(0, index-1);
            if(getRadioButtonAt(index).enabled || ignoreEnabled){
                selectIndex(index);
            }
        }
 
        public function moveRight(ignoreEnabled:Boolean=false):void{
            var index:int = getCurrentIndex();
            index = Math.min(numRadioButtons-1, index+1);
            if(getRadioButtonAt(index).enabled || ignoreEnabled){
                selectIndex(index);
            }
        }
 
    }
}
// IndexedRadioButtonGroup.as
package com.designoidgames.ui
{
	import flash.events.Event;
	import flash.utils.getTimer;

	import mx.core.IFlexDisplayObject;

	import spark.components.RadioButtonGroup;

	public class IndexedRadioButtonGroup extends RadioButtonGroup
	{

		public function IndexedRadioButtonGroup(document:IFlexDisplayObject=null)
		{
			super(document);
		}

		public function getCurrentIndex():int{
			for(var i:int=0;i
<this.numRadioButtons;i++){
				if(getRadioButtonAt(i) == this.selection){
					return i;
				}
			}

			return -1;
		}

		public function selectIndex(index:int):void{
			selection = getRadioButtonAt(index);
			dispatchEvent(new Event(Event.CHANGE));
		}

		public function moveLeft(ignoreEnabled:Boolean=false):void{
			var index:int = getCurrentIndex();
			index = Math.max(0, index-1);
			if(getRadioButtonAt(index).enabled || ignoreEnabled){
				selectIndex(index);
			}
		}

		public function moveRight(ignoreEnabled:Boolean=false):void{
			var index:int = getCurrentIndex();
			index = Math.min(numRadioButtons-1, index+1);
			if(getRadioButtonAt(index).enabled || ignoreEnabled){
				selectIndex(index);
			}
		}

	}
}

The next two classes are the MovieClipButton and a static skin class for it. This is useful when you want to use embedded MovieClips, like when you have a lot of material inside the Flash IDE and you export it as an .SWC file into your project. The MovieClipButton class is extremely simple, in fact it only adds one method to the spark Button called 'source' (other spark components like Image use the same).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// MovieClipButton.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
          xmlns:s="library://ns.adobe.com/flex/spark"
          xmlns:mx="library://ns.adobe.com/flex/mx" useHandCursor="true" buttonMode="true">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
 
    <fx:Script>
        <![CDATA[
            public var source:Class;
        ]]>
    </fx:Script>
 
</s:Button>
// MovieClipButton.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
		  xmlns:s="library://ns.adobe.com/flex/spark"
		  xmlns:mx="library://ns.adobe.com/flex/mx" useHandCursor="true" buttonMode="true">
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>

	<fx:Script>
		<![CDATA[
			public var source:Class;
		]]>
	</fx:Script>

</s:Button>

Then you supply a skin class for the button, this is the simplest one. It only tries to set the current frame of the MovieClip to a frame with the same name as the current state. Also if the MovieClip has a text label like most buttons do, you can change the text through MXML. Just make sure it's called "label" inside the MovieClip.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// StaticButtonSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
 
<!--- The default wireframe skin class for the Spark Button component.
        Skin classes in the wireframe package are useful for using as a simple base for a custom skin.
 
       @see spark.components.Button
 
      @langversion 3.0
      @playerversion Flash 10
      @playerversion AIR 1.5
      @productversion Flex 4
-->
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
                    creationComplete="creationCompleteHandler(event)" alpha.disabled="0">
    <fx:Metadata>
        [HostComponent("com.designoidgames.ui.MovieClipButton")]
    </fx:Metadata>
 
    <fx:Script>
        <![CDATA[
            import mx.events.FlexEvent;
 
            private var mc:MovieClip;
 
            override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void{
                super.stateChanged(oldState,newState,recursive);
 
                if(mc==null) return;
 
                mc.gotoAndStop(newState);
            }
 
            protected function creationCompleteHandler(event:FlexEvent):void{
                mc = new (hostComponent as MovieClipButton).source();
                mcHolder.addChild(mc);
 
                mc.gotoAndStop(currentState);
 
                if(hostComponent.label) mc.label.text = hostComponent.label;
            }
 
        ]]>
    </fx:Script>
 
    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>
 
    <s:SpriteVisualElement id="mcHolder"/>
 
</s:SparkButtonSkin>
// StaticButtonSkin.mxml
<?xml version="1.0" encoding="utf-8"?>

<!--- The default wireframe skin class for the Spark Button component.
        Skin classes in the wireframe package are useful for using as a simple base for a custom skin.

       @see spark.components.Button

      @langversion 3.0
      @playerversion Flash 10
      @playerversion AIR 1.5
      @productversion Flex 4
-->
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
    				creationComplete="creationCompleteHandler(event)" alpha.disabled="0">
	<fx:Metadata>
		[HostComponent("com.designoidgames.ui.MovieClipButton")]
	</fx:Metadata>

	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;

			private var mc:MovieClip;

			override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void{
				super.stateChanged(oldState,newState,recursive);

				if(mc==null) return;

				mc.gotoAndStop(newState);
			}

			protected function creationCompleteHandler(event:FlexEvent):void{
				mc = new (hostComponent as MovieClipButton).source();
				mcHolder.addChild(mc);

				mc.gotoAndStop(currentState);

				if(hostComponent.label) mc.label.text = hostComponent.label;
			}

		]]>
	</fx:Script>

    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>

	<s:SpriteVisualElement id="mcHolder"/>

</s:SparkButtonSkin>

Penalty Cup Champion !!!

2010 October 10
by admin


Been working hard on a new Facebook based football game. More info soon!

Demolition Dude released!

2010 March 8
by admin

Demolition Dude has been released, first exclusively on Armor Games.
After a week, the viral version will be out without a sitelock.

Play it now.

Designoid Games site is up!

2010 March 4
tags:
by admin

Designoid Games is a new independent Flash game company.

The first game to be officially released by Designoid Games is going to be Demolition Dude this week or early next week. Stay tuned for that stuff.