@James, I managed to tweak my platform code so it is ok now. Thanks for your generosity!
Joakim [import]uid: 81188 topic_id: 20965 reply_id: 83360[/import]
@James, I managed to tweak my platform code so it is ok now. Thanks for your generosity!
Joakim [import]uid: 81188 topic_id: 20965 reply_id: 83360[/import]
Ok, this one is maybe an easy one?
Is there something I can do by code in the event onFrame to “slow down” my moving player in the physics world?
if(ball.speed.x \> 15 or ball.speed.y \> 15) then
ball.speed.x = 15
ball.speed.y = 15
end
[import]uid: 81188 topic_id: 20965 reply_id: 83369[/import]
JT,
Basically I would like to have 3-4 predetermined paths. All starting with the same segment then have a “fork-in-the-road”.
At the point of the “intersection” i want the user to pick the direction they we to go. …
With this, i need to know how to go forward & reverse repeatedly; changing the “intersection” choice at will.
(also if the try to travel past the intersection without changing it the object will crash/explode.
Is this something that can be done without physics? I am not sure I want to tackle that yet.
If this is too much I completely understand. Maybe if you wouldn’t mind you can guide/Tutor me along the way.
Thanks for your assistance and direction.
Rob
rob at katnapapps [dot] com
[import]uid: 16527 topic_id: 20965 reply_id: 83387[/import]
Hey James,
sorry for the late response but I’m having a rough time figuring out how to send you a private message or email… Can you provide me your email address or let me know how to send you a pm and I’ll send along my lua file.
Thanks so much for this! [import]uid: 47361 topic_id: 20965 reply_id: 83416[/import]
@Mobilefun
That’s never happened to me and I can’t reproduce this issue. I’m really not sure how to tackle that one until I can at least recreate it. Is there something you may have done to create it?
@Blickon
I don’t think there’s a way right now to stop the separating effect because it would involve modifying the pixels of the graphics. The methods I can think of right now is trying to mask the “breaking” effect you get from the joints. I would suggest trying to use smaller joint objects at a higher number for your elastic effect.
That should make the the “breaking” effect look less obvious ( but I’m not sure how it will affect your performance ). If you have some code that you are already working on, let me see it and I could test it for you.
@jk
Sure. If you are using physics, you can set an impulse force negative to the current velocity that the player has. If your speed is done by moving it through the x and y coordinates, keep a universal variable that you use to determine speed and do subtraction on it based on the event frame.
Also, if you’re using animations and you want the effect of the animation slowing down, you can use the timescale property sprites have that determine their animation speed ( 1 is default ). Let me know if this helps.
@Rob
You can do this without physics, but you will probably run into performance issues because you want to do checks based on where the player is, but if you’d like to try, you can make an event listener that always runs and in it you translate the x and y coordinates along the path you want.
My advice would be to have the paths you have in that link, but have them set up with invisible checkpoint objects equally along the path. When the person signals to take a turn, you make a check to determine the current location of their car along a given path. If there is a checkpoint nearby, they become jointed to that and the checkpoint runs the path with the object being dragged along with it. When the person detaches from the checkpoint, the checkpoint goes back to its original position and you can select it again.
Going forward and reverse would be based on a value belonging to the persons car. When the car attaches to the checkpoint, the checkpoint checks if the car wants to go forward or backward. If forward, then the checkpoint moves to the next highest part of the path and vice versa.
I know this is a lot, but if you need any more assistance while making the code or need any more clarification, please let me know.
@Ram
If you need to send me your code, please send it at jamestimberlakejr[at]gmail[dot]com for your code submission, but make sure to post here so I know to check.
[import]uid: 49520 topic_id: 20965 reply_id: 83466[/import]
I’ve been doing something similar (helping out on the forums), but I like your approach. A direct offer to help.
I will offer the same thing. Anyone that needs help can contact me at: ken[at]homebrewsoftware[dot]com
I cannot promise to solve all questions, but I will do what I can to help out.
Also, if you’ve already asked james for help, I don’t want to interfere in any support issues he is working on. Please ask ONE of us for help, not both of us unless the first person you ask says he doesn’t have time.
In general I prefer to post solutions to problems here on the forums, so other users can learn too. However, if you have something you want kept private I will respect that as long as you let me know that upfront. [import]uid: 16734 topic_id: 20965 reply_id: 83478[/import]
WOW @Ken, that`s amazing! Thanks James & Ken for offering free help! OMG it is awesome from both of you IMHO!
Cheers,
Rodrigo. [import]uid: 89165 topic_id: 20965 reply_id: 83483[/import]
Hi jamestimberlakejr, thanks for all your availability, how i can send you the code? [import]uid: 26056 topic_id: 20965 reply_id: 83508[/import]
Hi James … great idea and offer
would you like to see this :
2 Questions regarding “Page Curl” :
http://developer.anscamobile.com/node/20435
thanks alot [import]uid: 95767 topic_id: 20965 reply_id: 83514[/import]
I added two variables to get the current velocity.
In my onFrame event I was checking if they went to far and did a reverse of the “power” - but that made my player just bumping around uncontrolled. Do you think you can provide some small code samples?
Joakim [import]uid: 81188 topic_id: 20965 reply_id: 83522[/import]
@Ken,
That’s awesome. I’m glad that someone else is also doing this too. I’ll send you an email.
@Blickon
You can send me your code at jamestimberlakejr[at]gmail[dot]com
@iAZZ
I’ll take a look at it tonight and see what I can do.
@jk
I need to see the way you’re doing it so I can point you into the right direction. Post me your code of how you’re doing it and I can revise it. If you don’t feel comfortable with that, then use email. [import]uid: 49520 topic_id: 20965 reply_id: 83553[/import]
@Ken,
That’s awesome. I’m glad that someone else is also doing this too. I’ll send you an email.
@Blickon
You can send me your code at jamestimberlakejr[at]gmail[dot]com
@iAZZ
I’ll take a look at it tonight and see what I can do.
@jk
I need to see the way you’re doing it so I can point you into the right direction. Post me your code of how you’re doing it and I can revise it. If you don’t feel comfortable with that, then use email.
@Rc, Thanks. I really appreciate the support. [import]uid: 49520 topic_id: 20965 reply_id: 83554[/import]
Hi, well I maybe looks stupid but I couldn’t think of any other direction then this.
I putted it in onFrame event…
[code]
–============================================================
– FRAME LISTENER
–============================================================
local function onFrame()
Particles.Update()
–Check if game is running
if(isPlaying) then
–Check speed of player and put on brakes if he is going to fast…
vx, vy = ball:getLinearVelocity()
if(vx > 200) then
ball:applyLinearImpulse( -200, 0, ball.x, ball.y )
end
–Control camera movment
gameGroup.x = (ball.x * -1)+240
if(ball.y<250) then
if(ball.y>-100) then
gameGroup.y = ((ball.y * -1) +250)-5
ball.jumping = true
if gameGroup.y < 1 then
gameGroup.y=1
end
end
end
–Move the parallax
myParallax:setPosition(myParallax.position.x + lastBallX - ball.x, 0)
lastBallX = ball.x
lastBallY = ball.y
–Check if player is on moving platform - if so, make it follow
if attachedPlatform then
ball.x = ActivePlatform.x - PlatformOffset
ball.jumping = true
end
end
end
[/code] [import]uid: 81188 topic_id: 20965 reply_id: 83561[/import]
@ jamestimberlakejr
Just sent you an email. Thanks! [import]uid: 47361 topic_id: 20965 reply_id: 83592[/import]
@jk,
Why not try modifying the velocity of the object directly then?
[lua] if(vx > 200) then
– use zero to stop, -200 to go backwards
ball:setLinearVelocity( -200, vy )
end[/lua]
Try this and let me know if it helps.
@iazz,
Can I see the code you’re working with so I can see the problem you’re having? I wasn’t able to do it with the code I saw there. [import]uid: 49520 topic_id: 20965 reply_id: 83857[/import]
@James, that did the trick. Thanks!
Joakim [import]uid: 81188 topic_id: 20965 reply_id: 83935[/import]
Hi james , here is the full code :
[code]-- hide the status bar
display.setStatusBar( display.HiddenStatusBar )
– create example pages
local page1 = display.newImageRect( “page1.jpg”, display.contentWidth, display.contentHeight )
page1:setReferencePoint( display.TopleftReferencePoint )
page1.x, page1.y = display.contentWidth*0.5, display.contentHeight*0.5
local page2 = display.newImageRect( “page2.jpg”, display.contentWidth, display.contentHeight )
page2.x, page2.y = display.contentWidth*0.5, display.contentHeight*0.5
page2:toBack()
local page3 = display.newImageRect( “page3.jpg”, display.contentWidth, display.contentHeight )
page3:setReferencePoint( display.TopleftReferencePoint )
page3.x, page3.y = display.contentWidth*0.5, display.contentHeight*0.5
page3:toBack()
local page4 = display.newImageRect( “page4.jpg”, display.contentWidth, display.contentHeight )
page4.x, page4.y = display.contentWidth*0.5, display.contentHeight*0.5
page4:toBack()
local curlPage = display.newImageRect( “curlPage.png”, display.contentWidth, display.contentHeight )
curlPage.x, curlPage.y = display.contentWidth*0.5, display.contentHeight*0.5
curlPage.isVisible = false
– group to hold the page that will be turned (as well as the “curl” page)
local turnGroup = display.newGroup()
– The following function will turn the page “back”
local function gotoPrevious( curlPage, time )
local time = time or 500
curlPage.isVisible = true
local hideCurl = function()
curlPage.isVisible = false
turnGroup:setMask( nil )
end
transition.to( turnGroup, {maskX=display.contentWidth*0.5+100, time=time } )
transition.to( curlPage, { rotation=45, x=display.contentWidth+(display.contentWidth*0.10)
, y=display.contentHeight + (display.contentHeight*0.25), time=time, onComplete=hideCurl })
end
– The following function will turn the page “forward”
local function gotoNext( currentPage, curlPage, time )
– add “pages” to page turning group
turnGroup:insert( currentPage)
turnGroup:insert( curlPage )
– mask should match dimensions of content (e.g. content width/height)
local curlMask = graphics.newMask( “mask_640x960.png” ) – iPhone portrait
–local curlMask = graphics.newMask( “mask_768x1024.png” ) – iPad portrait
turnGroup:setMask( curlMask )
– set initial mask position
turnGroup.maskX = display.contentWidth * 0.5+100
turnGroup.maskY = display.contentHeight * 0.5
– prepare the page-to-be-turned and the curl image
currentPage:setReferencePoint( display.BottomRightReferencePoint )
curlPage:setReferencePoint( display.BottomRightReferencePoint )
curlPage.rotation = 45
curlPage.x = display.contentWidth+(display.contentWidth*0.10)
curlPage.y = display.contentHeight + (display.contentHeight*0.25)
curlPage.isVisible = true
– show pagecurl animation and transition away (next page should already be in position)
local time = time or 500
transition.to( turnGroup, { maskX=-display.contentWidth*0.75, time=time } )
transition.to( curlPage, { rotation=0, x=0, y=display.contentHeight+20, time=time} )
curlPage.yScale = curlPage.y * 0.2
end
local function swipe(event)
local swipeLength = math.abs(event.x - event.xStart)
local currentPage = event.target
if event.phase == “moved” then
if event.xStart > event.x then
gotoNext (currentPage, curlPage, 1000)
elseif event.x > event.xStart then
gotoPrevious(curlPage,1000)
end
end
return true
end
page1:addEventListener( “touch” , function() gotoNext( page1,curlPage,1000 ) return true end )
page2:addEventListener( “touch” , swipe )
page3:addEventListener( “touch” , swipe )
page4:addEventListener( “touch” , function() gotoPrevious(curlPage,1000) return true end )[/code]
Notes :
Thanks
[import]uid: 95767 topic_id: 20965 reply_id: 83977[/import]
@iAZZ,
For some reason I didn’t see your reply. I’ll get on this evening and give you a response. [import]uid: 49520 topic_id: 20965 reply_id: 84964[/import]
@James, I am having problems and posted this a couple of days…Is it possible for you to just check if you can see any strange things going on…or could this be a corona bug?
https://developer.anscamobile.com/forum/2012/02/04/vertical-and-horizontal-moving-platform-problems
Best regards, Joakim [import]uid: 81188 topic_id: 20965 reply_id: 85022[/import]
thanks james … waiting for your response
[import]uid: 95767 topic_id: 20965 reply_id: 85027[/import]