Previously touch/mouse/key events are dispatched to all sprites on the stage. Now I'm holding a list that contains the sprites only with touch/mouse/key events registered. So that now I don't traverse the whole stage tree when user touches or moves the mouse etc.
@Atilim, so no more hitTests and stuff to check, right? You are doing that from the API rather than from the user code. That is going to be wonderful...
However we can still use the HitTest function, right?
Previously touch/mouse/key events are dispatched to all sprites on the stage. Now I'm holding a list that contains the sprites only with touch/mouse/key events registered. So that now I don't traverse the whole stage tree when user touches or moves the mouse etc.
Now you keep a list of sprites with these events registered, and call dispatchEvent on each of these sprites, is that right?
In the past I thought you keep a list of "listeners" for each type of touch/mouse/key events , so I mentioned the broadcast event here
@Atilim, so no more hitTests and stuff to check, right? You are doing that from the API rather than from the user code. That is going to be wonderful...
However we can still use the HitTest function, right?
I'm afraid not! to my understanding, what atilim did is just ignored the sprites that not insterested in these events.
However we can still use the HitTest function, right?
I'm afraid not! to my understanding, what atilim did is just ignored the sprites that not insterested in these events.
@Alex, I thought HitTest was independent of any touch/etc. It is just a function that takes an object and a point and returns if the point is in the bounding rect of that object or not.
It is useful to determine if the point is inside or outside of the object, like a MOUSE_OUT event.
I think it's just as @alexzheng nothing changed on our part (still need to do hittestpoints to check if this object was hit or not). Only difference is it will be dispatched only to objects that are listening and not to all objects.
Thanks for implementing Application:getScreenDensity(). This is important. The app can now detect if the device is big or small and adjust the size of the menus and stuff.
is there an error in Application:getScreenDensity() ? When calling on Android, it works great. On my iPhone, it's not available as it looks like. Although I am trying to evaluate to nil, I am getting an error on my iPhone:
main.lua:27: attempt to call method 'getScreenDensity' (a nil value)
since I am not really a LUA expert, what's wrong here?
if (application:getScreenDensity() ~= nil) then local sdens = application:getScreenDensity() -- do something with it... end
@Radiesel can you double check if you've installed the latest player (2012.09.2) to your iPhone? If you've already installed, then I can check it on my side.
Comments
So what does "Optimized Touch/Mouse/Key events." actually means?
Did you create some specific index for them?
Previously touch/mouse/key events are dispatched to all sprites on the stage. Now I'm holding a list that contains the sprites only with touch/mouse/key events registered. So that now I don't traverse the whole stage tree when user touches or moves the mouse etc.
Likes: Nascode, nextgamevertex, Chang, OZApps, alexzheng, hgvyas123, deniz, duke2017
However we can still use the HitTest function, right?
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
In the past I thought you keep a list of "listeners" for each type of touch/mouse/key events , so I mentioned the broadcast event here
http://www.giderosmobile.com/forum/discussion/287/suggestion-for-custom-events#Item_1
and I thought it will not take much work to do this if you already do touch/mouse/key this way.
https://sites.google.com/site/xraystudiogame
https://sites.google.com/site/xraystudiogame
Bug: If a listener is removed within a listener, indices can shift.
Maybe you can add an option to addEventListener to remove the listener after called once, just as the once function do in nodejs.
https://sites.google.com/site/xraystudiogame
It is useful to determine if the point is inside or outside of the object, like a MOUSE_OUT event.
@Atilim, would you want to confirm that please.
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
https://sites.google.com/site/xraystudiogame
main.lua:27: attempt to call method 'getScreenDensity' (a nil value)
since I am not really a LUA expert, what's wrong here?
if (application:getScreenDensity() ~= nil) then
local sdens = application:getScreenDensity()
-- do something with it...
end
Thanks!!
Michael
OK, don't understand this - it's working now. It's returning valid density on iPhone...
You know the famous last words? "I didn't change anything...."
Sorry for confusion...
best regards
Michael