Touch hitbox

Can I change the touch hitbox of an object without using “shape” and adding a physich body (if this works) to it?

Touch or collision?

Physics is for collision, not touches.

You can have these kinds of touch areas (not hit boxes which are physics concepts):

  • Entire rectangle of newRect() or newImageRect()
  • Entire circle of new newCircle()
  • Opaque portion of any of the above using isHitMasked property and a partially opaque/partially transparent fill texture OR a similar texture used as a mask.

http://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015/02/isHitMaskedHelp

Touch

Can i appy the mask to buttons made with widget.newButton?

I’m sure you can apply masks to widget buttons, but  you’ll need to dig into the structure of the button a bit to see how best to do it.

Widget buttons are composite objects (groups w/ objects in them) and the structure of the buttons is not readily exposed. That said, you can puzzle it out.

Of course you could simply make your own custom buttons and listeners too.

I’m hoving some troubles with masking, the “buttons” i’m using are some isometric tiles and the mask doesn’t work properly because all the screen where the tiles should be is complatly black

Screenshot_31.png

mask.png

grass_tile.png

Make sure your mask follows the mask size rules, etc:

https://docs.coronalabs.com/daily/api/library/graphics/newMask.html

I updated the mask, nothing changed

Other ideas?

Also how do you deal with the fact that you can’t call a function that is written after the line where u call it? is there a workaroud for this? it’s really annoying to me

I think you’re making this way too complicated by trying to squeeze code into an active project when you don’t yet have a handle on the concepts.

https://www.youtube.com/watch?v=j2WkZPgGAdA&feature=youtu.be

Always, always, always make a test case and figure out the one thing you’re puzzling over first.  Squeezing an unknown into a project working with other unknowns (widget buttons in this case) will only hose you up.

Also, once you are focused on the simplest case, then you can read the docs and find your answers.  This stuff is all there in the docs, but if you’re distracted by widget button questions and the other things going on in your project… it will be too hard to stay on track and get it working.

Here is a working example of hit masking with touches using your grass tile and a modified variant (not yet tested on devices) of your mask.

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/08/hitmasking.zip

Note: I won’t be answering any questions about making this work w/ widget buttons because from what I see of what you seem to be trying to do, you ought to make your own simpler touch objects.  i.e. Make my touch listener more robust and you’re golden.

Oh, and I don’t answer unrelated add-on questions.  Your add-on question was about scope and visibility.  Post a new concise question to the forums showing your example code and problem with not being able to call the function.  That way the discussion stays focused and stays useful for future readers.  Posts with multiple unrelated discussions have low future value to people with questions of their own that may be related to the original topic.

Touch or collision?

Physics is for collision, not touches.

You can have these kinds of touch areas (not hit boxes which are physics concepts):

  • Entire rectangle of newRect() or newImageRect()
  • Entire circle of new newCircle()
  • Opaque portion of any of the above using isHitMasked property and a partially opaque/partially transparent fill texture OR a similar texture used as a mask.

http://github.com/roaminggamer/RG_FreeStuff/tree/master/AskEd/2015/02/isHitMaskedHelp

Touch

Can i appy the mask to buttons made with widget.newButton?

I’m sure you can apply masks to widget buttons, but  you’ll need to dig into the structure of the button a bit to see how best to do it.

Widget buttons are composite objects (groups w/ objects in them) and the structure of the buttons is not readily exposed. That said, you can puzzle it out.

Of course you could simply make your own custom buttons and listeners too.

I’m hoving some troubles with masking, the “buttons” i’m using are some isometric tiles and the mask doesn’t work properly because all the screen where the tiles should be is complatly black

Screenshot_31.png

mask.png

grass_tile.png

Make sure your mask follows the mask size rules, etc:

https://docs.coronalabs.com/daily/api/library/graphics/newMask.html

I updated the mask, nothing changed

Other ideas?

Also how do you deal with the fact that you can’t call a function that is written after the line where u call it? is there a workaroud for this? it’s really annoying to me

I think you’re making this way too complicated by trying to squeeze code into an active project when you don’t yet have a handle on the concepts.

https://www.youtube.com/watch?v=j2WkZPgGAdA&feature=youtu.be

Always, always, always make a test case and figure out the one thing you’re puzzling over first.  Squeezing an unknown into a project working with other unknowns (widget buttons in this case) will only hose you up.

Also, once you are focused on the simplest case, then you can read the docs and find your answers.  This stuff is all there in the docs, but if you’re distracted by widget button questions and the other things going on in your project… it will be too hard to stay on track and get it working.

Here is a working example of hit masking with touches using your grass tile and a modified variant (not yet tested on devices) of your mask.

https://github.com/roaminggamer/RG_FreeStuff/raw/master/AskEd/2016/08/hitmasking.zip

Note: I won’t be answering any questions about making this work w/ widget buttons because from what I see of what you seem to be trying to do, you ought to make your own simpler touch objects.  i.e. Make my touch listener more robust and you’re golden.

Oh, and I don’t answer unrelated add-on questions.  Your add-on question was about scope and visibility.  Post a new concise question to the forums showing your example code and problem with not being able to call the function.  That way the discussion stays focused and stays useful for future readers.  Posts with multiple unrelated discussions have low future value to people with questions of their own that may be related to the original topic.