Help needed in fixing character animation

I am aware, but this does not occur with mine. I will keep digging through this demo and see what I can find.

Yes, I understand, but you should probably re-build your controller around this model.

Note that the visual “D pad” is just an overlay over actual sensory objects. Comment out these two lines and you can see them. Those could be made into your arrow graphics or whatever.

  1. –> btn.isVisible = false

  2. –> btn.isHitTestable = true

Brent

Ah, this demo moves the character manually, I move the character with setLinearVelocity. No wonder. Well, I will look into replicating this for my project.

Could you possibly wait a day or so on this while I finish up the tutorial? I think it will exhibit a more simple way for you to build your directional controls…

Brent

Of course. I need a bit of a break. 

As promised, here it is! I think this should help solve your virtual controller issues:

https://docs.coronalabs.com/tutorial/events/continuousActions/index.html

Brent

Thanks for this lengthy tutorial, Brent! I think I need to restart on my character movement, to fix things up a little.

I also placed the code of your tutorial in a stand-alone example and the same happens.

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

@Brent, I took apart the sample the “InputDevices” sample and I was able to combine it with the sample I sent you, and there were no issues when I used frame by frame movement. However, I could not get it to work with linear velocity. How could I achieve this?

I looked at the code and you’re never “stopping” linear velocity. Why not just use the example in the tutorial? I tested it with linear velocity and it works just fine. No issues at all in my tests.

Brent

Can you send me a zip file of one of your tests? In case, something is wrong on my side.

Just copy the one from the tutorial, under “Virtual Directional Pad” > “Physics-Based Movement”. It’s like 45 lines total and it’s the same test I used to write the tutorial.

Is setting it to 0, 0 not stopping it? The code is in the ended phase. PS (I am talking about the first zip file)

Yes 0,0 stops it, but it depends where you put it. Really, the tutorial solves it. I can’t advise you use the “InputDevice” model with physics any longer.

Brent

Ok, here is what I have now:

local function move( event ) if ( event.phase == "began" ) then -- Register movement if ( event.target.isPressed == false ) then if ( event.target.ID == "left" ) then character:setLinearVelocity( -100, 0 ) elseif ( event.target.ID == "right" ) then character:setLinearVelocity( 100, 0 ) end end event.target.isPressed = true elseif ( event.phase == "moved" ) then -- Check if touch moves inside rectangular bounds if ( event.x \> event.target.contentBounds.xMin+4 and event.x \< event.target.contentBounds.xMax-4 and event.y \> event.target.contentBounds.yMin+4 and event.y \< event.target.contentBounds.yMax-4 ) then event.target:dispatchEvent( { name="touch", phase="began", target=event.target } ) -- Else, dispatch an "ended" event else event.target:dispatchEvent( { name="touch", phase="ended", target=event.target } ) end elseif ( event.phase == "ended" and event.target.isPressed == true ) then -- Stop movement event.target.isPressed = false character:setLinearVelocity(0,0) end return true end

When I hold the button down and then drag out of its area the character continues moving.

That is why I asked for a zip file for your test because right now, I can’t find anything different between my code and the tutorial.

OK, here’s my “main.lua” file. Of course you’ll need to substitute in your button images…

Emmm… There’s no file here.

I have confirmed, it also occurs on your main.lua as well. 

https://www.youtube.com/watch?v=Ff7Uq8q-R30&feature=youtu.be