2 of 2
2
Double clicking (anyone have code that does this?)
Posted: 16 November 2008 03:07 PM   [ Ignore ]   [ # 16 ]
Jr. Member
RankRank
Total Posts:  161
Joined  2008-05-31

I was thinking of something like a game.

Say you had a bunch of things on the screen you had to squash/kill, and you are also given 3 bombs. By double tapping the stage you will kill all the things within some set radius. So then you want to double tap the stage nearest where the most enemies are.

cerupcat - 16 November 2008 02:59 PM

Can you give an example of when you would double tap the stage rather than put an object to double tap on?

Profile
 
 
Posted: 16 November 2008 03:29 PM   [ Ignore ]   [ # 17 ]
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  1509
Joined  2007-04-08

Hmm yeah, that makes sense.

Could be a bit tricky. Sounds like basically, you could use the code from rotatablesclable but then make it a bit more complex. Basically you have to save pairs of x/y coordinates within a given time period and then compare if another set within the same time period match. So lets say your doubletap rate is <= 250ms and in that 250ms you get:

(10, 25) <----1
(200, 12)
(150, 15)
(14, 22) <----2
(160, 165)

So you save all those pairs of coordinates and then loop through them to see if X and Y positions are within the set radius. From above, you can see that two do match. Then I would probably use the midpoint of X and Y maybe as the x/y point the ‘event’ occurred. The tricky part is adding and removing the saved coordinates from an array within a time period.

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 16 November 2008 03:42 PM   [ Ignore ]   [ # 18 ]
New Member
Avatar
Rank
Total Posts:  32
Joined  2008-10-12
cerupcat - 16 November 2008 03:29 PM

Hmm yeah, that makes sense.

Could be a bit tricky. Sounds like basically, you could use the code from rotatablesclable but then make it a bit more complex. Basically you have to save pairs of x/y coordinates within a given time period and then compare if another set within the same time period match. So lets say your doubletap rate is <= 250ms and in that 250ms you get:

(10, 25) <----1
(200, 12)
(150, 15)
(14, 22) <----2
(160, 165)

So you save all those pairs of coordinates and then loop through them to see if X and Y positions are within the set radius. From above, you can see that two do match. Then I would probably use the midpoint of X and Y maybe as the x/y point the ‘event’ occurred. The tricky part is adding and removing the saved coordinates from an array within a time period.

So, basically what I suggested earlier but with a little schema. Sorry to point that out.

 Signature 

Building MT for games projects : 24” LCD + LLP

Profile
 
 
Posted: 16 November 2008 03:50 PM   [ Ignore ]   [ # 19 ]
Jr. Member
RankRank
Total Posts:  161
Joined  2008-05-31

What about pulling the x/y of the double tap as it is now?
Is there a way to do this? (x/y on stage).

Profile
 
 
Posted: 16 November 2008 04:27 PM   [ Ignore ]   [ # 20 ]
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  1509
Joined  2007-04-08

lol, to make speps happy and to show i can spell his name, I give full credit to speps for what I said. rasberry

Really though, this should be part of the whole touch event system (and it’s on our list to implement).

noverflow: you could pull out the x/y by making them public like you said, but I believe the values are rerest if a touch isn’t in the radius. Therefore, it won’t work if there’s multiple people and you need to keep a list of all touches during that time period.

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 16 November 2008 04:32 PM   [ Ignore ]   [ # 21 ]
Jr. Member
RankRank
Total Posts:  161
Joined  2008-05-31

Yeah…
I may end up making my own class to do what I want.
How does one go about getting their class part of the SVN?

Also, a lot of what im trying to do is just try out everything I can think of, document it, and report back to the wiki about how to do it.
Basically give people starting places, and examples to build off of.
That and document everything you can do with all the classes.

Thanks a ton for all your help always.

cerupcat - 16 November 2008 04:27 PM

noverflow: you could pull out the x/y by making them public like you said, but I believe the values are rerest if a touch isn’t in the radius. Therefore, it won’t work if there’s multiple people and you need to keep a list of all touches during that time period.

Profile
 
 
Posted: 16 November 2008 05:44 PM   [ Ignore ]   [ # 22 ]
New Member
Avatar
Rank
Total Posts:  32
Joined  2008-10-12
cerupcat - 16 November 2008 04:27 PM

lol, to make speps happy and to show i can spell his name, I give full credit to speps for what I said. rasberry

Really though, this should be part of the whole touch event system (and it’s on our list to implement).

noverflow: you could pull out the x/y by making them public like you said, but I believe the values are rerest if a touch isn’t in the radius. Therefore, it won’t work if there’s multiple people and you need to keep a list of all touches during that time period.

Actually, there was nothing personal about it. However, I will probably develop things for MT once I have mine and I would be happy to be able to help with development. I am fluent in ActionScript 3 (and Flex) and C++, contact me if you want some help on touchlib and/or tbeta.

 Signature 

Building MT for games projects : 24” LCD + LLP

Profile
 
 
Posted: 16 November 2008 06:12 PM   [ Ignore ]   [ # 23 ]
Administrator
Avatar
RankRankRankRankRankRank
Total Posts:  1509
Joined  2007-04-08

Hehe, I know speps. smile We welcome (and can use) your help along the way. smile

 Signature 

My Multitouch Blog
My Youtube
Multitouch FAQ - Need Help? Click here!

Profile
 
 
Posted: 19 November 2008 03:29 PM   [ Ignore ]   [ # 24 ]
Jr. Member
RankRank
Total Posts:  161
Joined  2008-05-31

So I have a class that extends rotatescalable and it makes a sprite.
In my document class, it places x number of these randomly on the stage.
I want to be able to double click them to remove them.

I assume this code needs to be on the class that makes the sprites, because the double click is not seen by the document class.

But the sprites are added to the stage via the document class.

How can I tell it to remove child when double clicked, when the code is separated like this?

Something like this:

package app.demo.MyTouchApp{

    import flash
.events.TUIO;// allows to connect to touchlib/tbeta
    
import flash.display.Sprite;

    public class 
MyTouchApp extends Sprite {
        
                
        
private var num:Number=5// number of rings to put
        
var ring:Ring//ring class (at bottom)

        
public function MyTouchApp():void {

            
//--------connect to TUIO-----------------
            
TUIO.init(this,'localhost',3000,'',true);
            
trace("MyTouchApp Initialized");
            
//----------------------------------------
            
            
            // put "num" rings randomly on the stage
            
for (var i:int 0numi++) {
                ring 
= new Ring();
                
ring.Math.random() * stage.stageWidth;
                
ring.Math.random() * stage.stageHeight;
                
addChild(ring);
            
}
        }

    }
}

import flash
.display.Sprite// ring class
import app.core.action.RotatableScalable;

class 
Ring extends RotatableScalable {

    
public function Ring() {
        
        
//---RotatableScalable options------------
            //noScale = true;
            
noRotate true;    
            
//noMove = true;
        //----------------------------------------
        
        
graphics.beginFill(0xffffff);
        
graphics.drawCircle(0,0,30);
        
graphics.endFill();
    
}

    
public override function doubleTap(){
    
//remove sprite.
    
}

}

Profile
 
 
Posted: 20 November 2008 08:44 PM   [ Ignore ]   [ # 25 ]
Jr. Member
RankRank
Total Posts:  161
Joined  2008-05-31

Figured it out.

So the remove child needs to be on the ring class that extends rotateScale.. Because it is the only one that can access the double click. But because it is removing an instance put on the stage via the calling class (calss that called an instance of the ring class) it needed to be.

public override function doubleTap(){
parent.removeChild(this)
}

So sad, i was only missing the parent.

Profile
 
 
   
2 of 2
2
 
‹‹ Drum Set      Sound Playing Issues ››