Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Free Developer Support
Started by jamestimberlakejr Jan 26 2012 02:27 AM

- - - - -
126 replies to this topic
[TOPIC CONTROLS]
Page 3 of 6 1 2 3 4 5 »
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#51

rarmstrong

[GLOBAL: userInfoPane.html]
rarmstrong
  • Observer

  • 29 posts
  • Corona SDK

Actually I recently had to put this project on the back-burner but James helped out a lot with sorting the list alphabetically. I have yet to get around to fast-jumping functionality although I'm imagining I'll have an easier time with that than I did with the sorting issue :)
uid: 47361 topic_id: 20965 reply_id: 88698


[TOPIC: post.html]
#52

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

Hey Everyone,

I know it looks like I kinda died for a while ( And I kinda did ). I had the tornado called life hit me... and hard too, lol. In any case I'm back and I'll be posting the resolutions to the code that's been fixed but I never posted on here. I'm just double checking the people who I haven't addressed yet and then posting the fixes later this week.
uid: 49520 topic_id: 20965 reply_id: 89953


[TOPIC: post.html]
#53

WauloK

[GLOBAL: userInfoPane.html]
WauloK
  • Contributor

  • 668 posts
  • Guests

Hi.

When you have time, are you able to take a look at some code I wrote for the 48 hour challenge and give me some advice and suggestions please? :)

Cheers.
uid: 10389 topic_id: 20965 reply_id: 90029


[TOPIC: post.html]
#54

KenRogoway

[GLOBAL: userInfoPane.html]
KenRogoway
  • Contributor

  • 272 posts
  • Corona SDK

@WauloK,

I'd be glad to take a look. You can email me: Ken at HomebrewSoftware dot com.

Ken
uid: 16734 topic_id: 20965 reply_id: 90038


[TOPIC: post.html]
#55

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

Sure. Just send me an email @ jamestimberlakejr[at] gmail [dot] com. I'll be looking at some code tonight and I can look at it then
uid: 49520 topic_id: 20965 reply_id: 90049


[TOPIC: post.html]
#56

WauloK

[GLOBAL: userInfoPane.html]
WauloK
  • Contributor

  • 668 posts
  • Guests

Thanks guys! :)
uid: 10389 topic_id: 20965 reply_id: 90059


[TOPIC: post.html]
#57

GP

[GLOBAL: userInfoPane.html]
GP
  • Observer

  • 12 posts
  • Guests

Hi James,

I have a 15 frame sprite that I'm controlling via drag. The sprite is a character that spins 360 degrees. If you drag your finger across the sprite more than 15 pixels it will load the previous or next frame based on the direction of the drag. This works great.

I am trying to figure out how to load additional frames based on the velocity of a flick during the drag event. Any ideas?

Thanks,

Greg

-- hide status bardisplay.setStatusBar(display.HiddenStatusBar)-- pipe terminal output to Sublime Text's build console; strip out on publishio.output():setvbuf("no")-- load classeslocal grabber = require("SpriteGrabber")-- set forward referencing & variableslocal spinNumlocal prevX = 0local dragDist = 0local math_abs = math.abslocal dragDistNum = 15local i-- make sprite clipslocal function makeClips1(num)	local spriteClips1 = {}	for i = 1, num do		spriteClips1["spin"..i] = {i,1,1,1}	end	return spriteClips1end-- load spriteslocal spritesheetSpin1 = grabber.grabSheet("ElephantSpin")local spin1 = spritesheetSpin1:grabSprite("Elephant",true,makeClips1(15))	local function makeSpin(e)	dragDist = math_abs(e.x - prevX)	local t = e.target	local phase = e.phase		if "began" == phase then        local parent = t.parent -- make image top-most object        parent:insert(t)        display.getCurrentStage():setFocus(t)        t.isFocus = true -- prevents touch events off target 		prevX = e.x -- store initial touch position	elseif t.isFocus then				if "moved" == phase then			if e.x > prevX and dragDist > dragDistNum then -- moving right				if spinNum < 15 then					spinNum = spinNum + 1				elseif spinNum == 15 then 					spinNum = spinNum - 14				end				print("Image # "..spinNum)				spin1:playClip("spin"..spinNum)			elseif  e.x < prevX and dragDist > dragDistNum then -- moving left				if spinNum > 1 then					spinNum = spinNum - 1				elseif spinNum == 1 then 					spinNum = spinNum + 14				end				print("Image # "..spinNum)								spin1:playClip("spin"..spinNum)			end						-- factor back swipDist			if e.x > prevX + dragDistNum or e.x < prevX - dragDistNum then				prevX = e.x			end		elseif "ended" == phase or "cancelled" == phase then			display.getCurrentStage():setFocus(nil)			t.isFocus = false		end	end	return trueend	 --set initial statelocal function init()	spin1:scale(1.35,1.35)	spinNum = 2	spin1:playClip("spin"..spinNum)	spin1:addEventListener("touch", makeSpin)endinit()
uid: 2108 topic_id: 20965 reply_id: 90988


[TOPIC: post.html]
#58

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

Hi GP,

I'll take a look at it and see what I can come up with.
uid: 49520 topic_id: 20965 reply_id: 91245


[TOPIC: post.html]
#59

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

@GP,
Try and see it this works out for you
--@start jt edit: hold previous time local prevTime--@end jt editlocal function makeSpin(e)        dragDist = math_abs(e.x - prevX)        local t = e.target        local phase = e.phase           if "began" == phase then        local parent = t.parent -- make image top-most object        parent:insert(t)        display.getCurrentStage():setFocus(t)        t.isFocus = true -- prevents touch events off target                 prevX = e.x -- store initial touch position        elseif t.isFocus then                           if "moved" == phase then                		                		--@start jt edits                		local newTime = event.time                		local velocity                		                		--now we get the velocity                		if prevTime ~= nil then                			local totalTime = newTime - prevTime                			velocity = dragDist/totalTime                			                		end                		                		--set the new previous time                		prevTime = newTime                		                		if velocity > 20--[[whatever number you want to use--]] then                			-- switch to some new frames                		end                		--@end jt edits                                        if e.x > prevX and dragDist > dragDistNum then -- moving right                                if spinNum < 15 then                                        spinNum = spinNum + 1                                elseif spinNum == 15 then                                         spinNum = spinNum - 14                                end                                print("Image # "..spinNum)                                spin1:playClip("spin"..spinNum)                        elseif  e.x < prevX and dragDist > dragDistNum then -- moving left                                if spinNum > 1 then                                        spinNum = spinNum - 1                                elseif spinNum == 1 then                                         spinNum = spinNum + 14                                end                                print("Image # "..spinNum)                                                              spin1:playClip("spin"..spinNum)                        end                                             -- factor back swipDist                        if e.x > prevX + dragDistNum or e.x < prevX - dragDistNum then                                prevX = e.x                        end                elseif "ended" == phase or "cancelled" == phase then                        display.getCurrentStage():setFocus(nil)                        t.isFocus = false                end        end        return trueend
uid: 49520 topic_id: 20965 reply_id: 91423


[TOPIC: post.html]
#60

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Hi James & Ken, I'm wondering if either one of you (or both of you) could help me out with Twitter integration. I've posted a cry for help here. Any input and, hopefully, generic sample code would be soo appreciated (and I'm sure tons of other users would love it too).

Naomi

uid: 67217 topic_id: 20965 reply_id: 91558


[TOPIC: post.html]
#61

KenRogoway

[GLOBAL: userInfoPane.html]
KenRogoway
  • Contributor

  • 272 posts
  • Corona SDK

@Naomi,

Twitter is very simple:

native.showWebPopup( x, y, width, height, "http://twitter.com/intent/tweet?text="..theString )
uid: 16734 topic_id: 20965 reply_id: 91569


[TOPIC: post.html]
#62

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Hey, Ken, thank you for your reply. What I want, though, is to avoid native.showWebPopup. Is there a way to implement Twitter without the use of native.showWebPopup??

Here are some of the posts that I looked at, but all of them appear to use native.showWebPopup:
http://developer.anscamobile.com/forum/2012/01/10/twitter-oauth
http://developer.anscamobile.com/code/oauth-library
http://techority.com/2011/05/26/post-to-twitter-from-your-application/

Here's the reason why I'd like to avoid using native.showWebPopup:
http://developer.anscamobile.com/forum/2012/01/25/memory-leak-webpopups

I thought this aggressive caching business wasn't all that bad, until I did some intense testing of my game that led to memory warning on console and eventually crashed my game…

Naomi
uid: 67217 topic_id: 20965 reply_id: 91578


[TOPIC: post.html]
#63

KenRogoway

[GLOBAL: userInfoPane.html]
KenRogoway
  • Contributor

  • 272 posts
  • Corona SDK

The problem you have is that you have to give the user some way to Log In and to do the actual "Tweet". Otherwise you could just use this:

system.openURL("https://twitter.com/intent/tweet?text=Test")
uid: 16734 topic_id: 20965 reply_id: 91581


[TOPIC: post.html]
#64

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

System.openurl will still open a web popup, its just opened by the system which might not make a difference in terms of memory. You could try it and I'm not sure if there is a difference in the call in terms of memory retention, but it should be essentially the same as using native.showWebPopup for all intents and purposes.

Have you tried internally making your own network call to twitter with the text as your post? Then you wouldn't need to use a web popup, but you can make tweets in the minimal way possible. For getting the username/password, you can make your own interface with a textfield where they can enter information for the tweet.

Let me know what you think.
uid: 49520 topic_id: 20965 reply_id: 91592


[TOPIC: post.html]
#65

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

@Ken, thank you for your thoughts and suggestions.

@James, internally making the network call sounds great to me. I did look at network.request API ( http://developer.anscamobile.com/node/5305 ), but I'm not sure how I may go about marrying the Twitter App with the network.request. I'd so appreciate it if you can put together some sort of generic sample code that we can all work off of.

Thanks again.

Naomi
uid: 67217 topic_id: 20965 reply_id: 91594


[TOPIC: post.html]
#66

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

@Naomi,

I'll see what I can do about it and get back to you either tonight or tomorrow.

uid: 49520 topic_id: 20965 reply_id: 91603


[TOPIC: post.html]
#67

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

@James, that sounds great. Thank you so much!

Naomi
uid: 67217 topic_id: 20965 reply_id: 91604


[TOPIC: post.html]
#68

GP

[GLOBAL: userInfoPane.html]
GP
  • Observer

  • 12 posts
  • Guests

Hi James,

Thanks so much for taking the time to help me out.

I looked over your code and tried to integrate it with mine, but cannot get it to behave as expected. I'd like the sprite to continue spinning for a bit after the swipe has stopped (based on velocity of flick). Perhaps an example for line #63 could help with my non-understanding.

I have zipped up my project along with the sprite so you can see the current state and my version of spinning.

http://db.tt/Irs5sLpm

Thanks again for your time, it's greatly appreciated.

Greg
uid: 2108 topic_id: 20965 reply_id: 91752


[TOPIC: post.html]
#69

mobilefun4me

[GLOBAL: userInfoPane.html]
mobilefun4me
  • Enthusiast

  • 48 posts
  • Corona SDK

Physics Button problem.

I have a physics based game using buttons. When a button falls, it may land on the floor on its right side, left side, upside down and occasionally right side up. I need it to fall, spin, bounce, etc. but always end up with the right side up. Can you suggest a way to do this? I'm using Storyboard.
uid: 6288 topic_id: 20965 reply_id: 91840


[TOPIC: post.html]
#70

WauloK

[GLOBAL: userInfoPane.html]
WauloK
  • Contributor

  • 668 posts
  • Guests

If something collides with my object, I detect it with Physics and set
myObjectRotated = true


Then, later in the game code:

if myObjectRotated == true then   transition.to(myObject, { time = 5000, rotation = 0 })   myObjectRotated = falseend
uid: 10389 topic_id: 20965 reply_id: 91842


[TOPIC: post.html]
#71

carlos m. icaza

[GLOBAL: userInfoPane.html]
carlos m. icaza
  • Corona Geek

  • 2,992 posts
  • Alumni

neat thread.. i just bumped into it...

woohoo +1

c
uid: 24 topic_id: 20965 reply_id: 91854


[TOPIC: post.html]
#72

jamestimberlakejr

[GLOBAL: userInfoPane.html]
jamestimberlakejr
  • Enthusiast

  • 86 posts
  • Corona SDK

@Naomi,

This twitter client is going to take some time to do. I need to work on it on the weekend and I'll show my results.

@Carlos,

I'm glad you like it. Just trying to do what we can.

@GP,

I tried this out and it seems to work. Try this:

main.lua
-- hide status bardisplay.setStatusBar(display.HiddenStatusBar) -- pipe terminal output to Sublime Text's build console; strip out on publishio.output():setvbuf("no") -- load classeslocal grabber = require("SpriteGrabber") -- set forward referencing & variableslocal spinNumlocal prevX = 0local prevY = 0local dragDist = 0local math_abs = math.abslocal dragDistNum = 15local i  -- make sprite clipslocal function makeClips1(num)        local spriteClips1 = {}        for i = 1, num do                spriteClips1["spin"..i] = {i,1,1,1}        end        ---@jt        --you need to add a full rotation to play when you want to spin it        --you will need to add sprites for a reversed spin effect        spriteClips1["fullSpin"] = {1,15,5000,0}        return spriteClips1end -- load spriteslocal spritesheetSpin1 = grabber.grabSheet("DragonSpin")local spin1 = spritesheetSpin1:grabSprite("Dragon",true,makeClips1(15))--local fullSprite = spritesheetSpin1:grabSprite("Dragon",true,makeClips1(15))--@start jt edit: hold previous timelocal prevTime--@end jt edit        local function makeSpin(e)        dragDist = math_abs(e.x - prevX)        local t = e.target        local phase = e.phase        if "began" == phase then                local parent = t.parent -- make image top-most object                parent:insert(t)                display.getCurrentStage():setFocus(t)                t.isFocus = true -- prevents touch events off target                prevX = e.x -- store initial touch position        elseif t.isFocus then                           if "moved" == phase then                        --@start jt edits                        local newTime = e.time -- renamed from event                        local velocity = 0 -- assigned value to prevent nil                        --set the new previous time                        prevTime = newTime                        --@end jt edits                                if e.x > prevX and dragDist > dragDistNum then -- moving right                                        if spinNum < 15 then                                                spinNum = spinNum + 1                                        elseif spinNum == 15 then                                                 spinNum = spinNum - 14                                        end                                        print("Image # "..spinNum)                                        spin1:playClip("spin"..spinNum)                                elseif e.x < prevX and dragDist > dragDistNum then -- moving left                                        if spinNum > 1 then                                                spinNum = spinNum - 1                                        elseif spinNum == 1 then                                                 spinNum = spinNum + 14                                        end                                        print("Image # "..spinNum)                                                                      spin1:playClip("spin"..spinNum)                                end                        -- factor back swipDist                        if e.x > prevX + dragDistNum or e.x < prevX - dragDistNum then                                prevX = e.x                        end                elseif "ended" == phase or "cancelled" == phase then                        display.getCurrentStage():setFocus(nil)                        t.isFocus = false                                                 --@start jt edits                        --we need to so all of our logiv in the end phase                       	local newTime = e.time                       	local x = e.x                       	local y = e.y                       	local velocity = 0                       	                       	                        -- we need to do some math here to get the speed used to get from one point to another                                               if prevTime ~= nil then                                local totalTime = newTime - prevTime                                local dist = math.sqrt(((x-prevX)*(x-prevX))+((y - prevY)*(y - prevY)))                                velocity = dist/totalTime                                --print('velocity is '..velocity)                        end                                               	-- if the velocity is greater than 20 , we'll play the animation at the current speed                        if velocity > 20 then                                -- switch to some new frames																local spinVelocity = velocity * 0.2								if spinVelocity > 16 then --the maximum you can have this value is 20 but i used 15									spinVelocity = 15								end																								spin1.timeScale = spinVelocity								spin1:playClip("fullSpin")																--now for the velocity to decrease during a certain period of time								--this gives the look that it's winding down								local function onSpriteSpin(event)									spin1.timeScale = spin1.timeScale - 0.2									print(spin1.timeScale)									if spin1.timeScale < 1 or spin1.timeScale == 1 then										spin1.timeScale = 1										spin1:pause()										spin1:removeEventListener('sprite',onSpriteSpin)									end								end																spin1:addEventListener('sprite',onSpriteSpin)								                        end                                                --@end jt edits                end        end        return trueend         --set initial statelocal function init()        spin1:scale(1.35,1.35)        spinNum = 2        spin1:playClip("spin"..spinNum)        spin1:addEventListener("touch", makeSpin)endinit()
uid: 49520 topic_id: 20965 reply_id: 91918


[TOPIC: post.html]
#73

Naomi

[GLOBAL: userInfoPane.html]
Naomi
  • Corona Geek

  • 2,303 posts
  • Corona SDK

Hi James, thank you so much for the follow up. I appreciate all you do, and look forward to what you may come up with -- and hopefully it won't be too complex for me :)

Naomi
uid: 67217 topic_id: 20965 reply_id: 91990


[TOPIC: post.html]
#74

GP

[GLOBAL: userInfoPane.html]
GP
  • Observer

  • 12 posts
  • Guests

Wow, this is impressive...thanks!

I followed your code comments and created the additional sprite frames to simulate a backwards spin. The only problem with this method is the sprite clip's starting frame (fired during the end phase) is not contiguous with the ending frame (fired during the moved phase). End result, the sprite jumps to the respective starting frames when flicking.

I tried replacing the clip's startFrame with the spinNum variable, but that throws off the frame count. Maybe add difference between spinNum and original startFrame, to get new startFrame, then subtract difference from totalFrames, then reset. Cannot seem to wrap my head around this one. Any ideas?

Also, is prevY and e.y even needed if spinning is only on a horizontal axis?

Here is the updated project: http://db.tt/Grt1xvcO
uid: 2108 topic_id: 20965 reply_id: 92112


[TOPIC: post.html]
#75

Emerson Hsieh

[GLOBAL: userInfoPane.html]
Emerson Hsieh
  • Contributor

  • 102 posts
  • Corona SDK

Hi,

I wonder if someone can answer this question : Is it possible to add a pinch-zoom function AND a pan function in a single scene? I tried it myself but the functions kept interfering.

any help will be appreciated
uid: 44110 topic_id: 20965 reply_id: 92393



[topic_controls]
Page 3 of 6 1 2 3 4 5 »
 
[/topic_controls]