HaxeFlixel how to fire touch event to fire when touching sprite - haxe

I have a sprite on the screen that I want to fire a event when touched. I managed it with the mouse event but can't get it work with touch input.
//This works for mouse. eg.
import flixel.input.mouse.FlxMouseEventManager;
...
add(sprite);
FlxMouseEventManager.add(sprite, onMouseDown, onMouseUp, onMouseOver, onMouseOut);
// Need to work out how to fire event for touch.
I would like the touch equivalent for a sprite.
FlxTouch???? (needs to be fixed)

Related

Calling OnDraw in MFC SDI application

I am trying to make a MFC SDI application in VC++ to draw different shapes on click of the respective button. We have written our code inside the OnDraw() function. But Ondraw gets automatically called on running the application. We want it to be called only on the onclick of respective button. How do we proceed..?
When a shape button is clicked set a member variable that remembers what you want to draw.
Call Invalidate. This will cause OnDraw to be called by the framework.
In OnDraw check the member variable and draw the shape.
You must permit OnDraw to draw every time it is called by the framework. That is how the window image is restored after being uncovered, unminimized, resized, etc.
You cant prevent that OnDraw is only called when you press a button.
OnDraw in a view is called when WM_PAINT arrives and asks the window to repaint itself. Not executing OnDraw would cause nothing to be drawn at all.
OnDraw is also called when your application is minimized and maximized again, or when the size of the window changes.
Also I can not think about a scenario, where I want drawing only when a button is pressed. You need to be more precise. here.
OnDraw, as xMRi said, is called by the framework ... but if you want to draw something only when you click on a button, why don't you create a member variable, setup when you click the button, and get count when OnDraw is executed ?
void CYourAppView::OnDraw(CDC* pDC)
{
// MFC code
if(m_bButtonWasClicked)
{
// draw what ever you want
}
}

In phaser.js capture touch events on the canvas

I'm trying to make a simple game that has a single input based on lessmilk.com's Flappy Bird tutorial. On the keyboard you hit space to jump, but on touch enabled devices I'd like to just have the users touch anywhere on the canvas to jump.
Looking at the input docs it seems straight forward to capture touch input for a sprite, but I'd like the user to be able click/touch anywhere.
What's the "Phaser way" to capture all touch events? Do I need to do something hacky like create an invisible sprite covering the entire canvas? Should I bypass the phaser and just attach DOM event handlers?
Seems like I'd been misunderstanding the role of phaser's input manager. I'd been trying to use game.input.touch to hook those events but I just needed to be using the higher level input.onDown event:
// click / touch to jump
game.input.onDown.add(this.jump, this);

blank screen after showing alert in j2me

I have developed a game but this is a serious problem I am facing. I don't have any threads in my code , but whenever I use alert
Display.setCurrent(my_alert)// my_alert has a timeout of 3000ms
then after this alert, a blank white screen appears.When the screen is pressed, then my game canvas reappears. Before setting alert, my game canvas of checkers board is set as the current display. This problems also appears after the automatic keypad lock.
This alert is vital for my game, Kindly suggest a solution.
Issues like that typically indicate missing or incorrect override of GameCanvas method showNotify():
The implementation calls showNotify() immediately prior to this Canvas being made visible on the display. Canvas subclasses may override this method to perform tasks before being shown, such as setting up animations, starting timers, etc. The default implementation of this method in class Canvas is empty.
Above method is invoked at return from Alert to prior screen. GameCanvas should somehow trigger repaint of the the screen (eg using repaint or flushGraphics methods), otherwise it will be displayed blank.
The fact that this problems also appears after the automatic keypad lock makes it even more likely that showNotify is not done right in your MIDlet.

Injecting Mouse Events in GTK (WebKitWebView)

I have a GTK window containing a WebKitWebView that shows a user interface. I receive touch information over USB from a touch panel.
How do I inject mouse down, dragged and up events into the web kit view, without having to move the actual mouse pointer (as there may be multiple touch screens connected to one machine that all need to function independently)?
You have to create an appropriate GDK Event (GdkEventButton for mouse button events) and put it in the event queue using
void gdk_event_put(const GdkEvent *event)
See the GDK documentation for details.

Altering the YUI menu's mousing behavior

I'm using Yui to build a "popup" menu that works a bit differently with the mouse than usual. This is not a ContextMenu, because I want it to respond to left clicks, and the ContextMenu seems bent on responding to right clicks.
Following the examples, if I do this, the menu comes up and everything is close to how I want it:
YAHOO.util.Event.addListener(myClickTarget, 'click', myThingGotClicked);
In my myThingGotClicked function, I manually set the menu's position and show() it.
My problem is that I want to "bind" the menu visibility to the state of the mouse button. That is, on a mouseDown, I want the menu to come up, and on a mouseUp, I want the menu to disappear (selecting the active item, if any). So, listening to the 'click' event doesn't do the right thing, because a "click" is only sent after mouseUp.
The "obvious" solution is to do this:
YAHOO.util.Event.addListener(myClickTarget, 'mousedown', myThingGotClicked);
But this doesn't work. Stepping through in a debugger, you can see that it does actually bring up the menu on a mousedown, but then something immediately hides the menu. At full speed, it looks like nothing happens at all.
Any thoughts?
The problem is that the MenuManager class listens for the mousedown event at the document level and hides all visible Menu instances. So, since you are building a unique sort of Menu implementation, you'll need to stop the propagation of the mousedown event inside your handler so that the MenuManager doesn't handle the event. Here is some pseudo code for you:
var myThingGotClicked = function (event) {
YAHOO.util.Event.stopPropagation(event);
// Do other stuff
};
YAHOO.util.Event.on(myClickTarget, 'mousedown', myThingGotClicked);
Todd
That's a bit closer, as the menu does pop up, but if you try to make a selection in the menu, the text selection of the page underneath goes sort of nuts. I also need to add a mouseup handler, I think, as the menu doesn't go down on mouse release.
What I really want here are menus that work like menus on every version of the Mac OS (until more recently when OS X added the "click to make the menu 'sticky' to the default behavior).

Resources