Draw method question (link included)

http://wikisend.com/download/126152/Impact.zip

Above is a link to an example of one of the drawing methods in an app I’m making. Click and drag the mouse to draw a line of little explosion thingies.

My question:

Is there a better way to do this? I’ve got like 8 of these, each with their own tables, index variables, and methods, and I can’t help but think I’m missing something. The code portion of the file is below in case you’re unable or too lazy to view my file (I don’t judge).

[blockcode]require “sprite”

local xx = 0
local yy = 0
local impacts = {}

local impactIndex = #impacts + 1

sheet8 = sprite.newSpriteSheet( “expSmallX.png”, 20, 20 )

local spriteSet8 = sprite.newSpriteSet(sheet8, 1, 7)
sprite.add( spriteSet8, “explode2”, 1, 7, 150, 1 )

local function justCut (self)
local child = self
child.parent:remove ( child )
self = nil
end

local impactDraw = function()
impacts[impactIndex] = sprite.newSprite( spriteSet8 )
impacts[impactIndex].x = xx
impacts[impactIndex].y = yy
impacts[impactIndex].myLabel = “impact”
impacts[impactIndex].rotation = math.random (359)
impacts[impactIndex]:prepare(“explode2”)
impacts[impactIndex]:play()
local ph = impacts[impactIndex]
local myclosure = function() return justCut( ph ) end
timer.performWithDelay(250, myclosure)
impactIndex = impactIndex + 1
end

local onTouch = function( event )
xx = event.x
yy = event.y
impactDraw()
end

Runtime:addEventListener( “touch”, onTouch )[/blockcode] [import]uid: 89724 topic_id: 16923 reply_id: 316923[/import]

looks good to me. and yes i did download it :slight_smile:

c [import]uid: 24 topic_id: 16923 reply_id: 63452[/import]

Ooh. Straight from the staff. Doesn’t get much surer than that.

But that’s just a fraction of my true power!

(sorry to do this, but no file hosting site would take this sucker except mediafire)

http://www.mediafire.com/?a7ibcexrwon8klq

That’s the whole game, so far. It’s not even nearly done, though it is playable, if you feel like giving it a shot. Just click to direct the Gatling gun. Clicking the bar to the right pauses.

When testing, though, I noticed a slight lag from time to time. If the game isn’t even done and I plan to incorporate several other onscreen events during gameplay, how am I going to avoid dropping frames like a pirate photographer?

(Sincerest apologies if the above attempt at humor has offended any pirates who may be reading this) [import]uid: 89724 topic_id: 16923 reply_id: 63493[/import]

Got a couple errors on that download :frowning:

I did however love the artwork :smiley:

I know I’m not as impressive as Carlos is but for what it’s worth I really enjoyed the first download too - looks cool :slight_smile:

Peach

PS - As a pirate, I do not take offense to your style of humor, although I cannot speak for the Captain. (He’s quite mad, you see.) [import]uid: 52491 topic_id: 16923 reply_id: 63734[/import]

To err is human.

I’ll try again

http://wikisend.com/download/110792/Gatling.zip

I tested that one. It should work fine.

Glad you liked the artwork. The background elements and explosions were made by Danc of Lost Garden, and the sprites the enemies are based on came from Daniel “Placky” Eriksson. I can edit and change, but for some reason creating art from scratch is difficult for me.

As far as impressiveness goes, I’d heard of you long before I’d heard of Carlos, so take from that what you will :wink: (I say you two should settle it Hey Arnold style: giant Q-tips, pool of Jello, balance beam, first one swimming in semisolids has to surrender their impressiveness).

And for the captain. I request a parlay. We can settle this like gentlemen. [import]uid: 89724 topic_id: 16923 reply_id: 63787[/import]

@ x2495iiii

I downloaded the .zip and when I tried to run it kept getting errors after
errors was un-playable I manage to fix enough errors to let me rotate
the character shooting down some zombies and tanks lol Let us know when
is out looking forward for Round 2 but this time with no errors!

PS: Quick question which route is taken on this app to make spawn characters
walk towards the character with the gun? I been breaking my head trying to
accomplish this and transition.to gets the job done but if I try to fling off
the object coming to center of screen I have to wait till transition is completed
so thats a huge NO and there is no transition.pause() API to help me. Would
really appreciate if you can point me in the right direction on how this was
accomplish on this game.

Keep up the great work ! [import]uid: 30314 topic_id: 16923 reply_id: 63947[/import]

Glad you like the app so far, but seriously what’s the deal with these errors? I guess I can keep trying, but why can’t I get a file uploaded?

As for the enemy motion, my guys calculate what direction they need to have velocity applied using geometry. It’s easy since the character doesn’t move, they just change their velocity at spawn time to move them in a straight line towards the character. When they hit his collision box, their linear velocity is set to zero.

Also, there is a cancel transition command (http://developer.anscamobile.com/reference/index/transitioncancel), but I’ve never used it. [import]uid: 89724 topic_id: 16923 reply_id: 63954[/import]

@ x2495iiii

The errors come when you run the app the download goes through just fine
have you try downloading it yourself and run it? I`m using build 639 and
tried it on latest stable build. Overall the game looks cool reminds me of
NES games lol let me know if you figure out how to make it run so I can go
for round 2. I manage to fix it enough to play it but still a lot of errors

And Thanks for help on accomplishing point A > point B not sure if I
quite understood i`m not a pro at programming lol but ill try figure it
out with your help thanks. [import]uid: 30314 topic_id: 16923 reply_id: 63955[/import]

I just tried downloading and running it. Works perfectly fine.

I’m using build 2011.591.

It’s supposed to look and sound like the old NES games, so mission accomplished. Again, thanks for the positive feedback.

And for the angle and linear velocity, you could try implementing it yourself, or you could try using the beebe games class, which lets you use extra methods, one of which is moveTowards, another of which is getAngleTo.

Link:
http://developer.anscamobile.com/code/beebegames-class [import]uid: 89724 topic_id: 16923 reply_id: 63957[/import]

@ x2495iiii

Thanks again for help I used Beebegames class before to save score
ill go over it to check out the moveTowards and getAngleTo hopefully
they can help me out, I just need images to spawn like your game and
go to middle but as they go ill fling them back out with multi puck sample.
I manage to do that just fine the problem was if i dont fling them they had
no movement they didnt kept going to the middle and I dont want that to
happend if the user doesnt fling it back out then the object keeps on route.

If you want to email me the working sample you have ill run it on 591
it should work if working for you (hopefully) and ill let you know.

Thanks,
LeivaGames@gmail.com [import]uid: 30314 topic_id: 16923 reply_id: 63958[/import]

Oh. Hey are your enemies regular physics bodies? Mine are sensors, so the movement is somewhat different since they don’t collide with each other. I’ll probably end up making them collision filters at some point like Matt Pringle told me to, but that’s a lesson for another day.

Sending it now. [import]uid: 89724 topic_id: 16923 reply_id: 63960[/import]

Still getting errors here too - the first one is related to the fact you reference “shotgunbutton.png” twice but it should read “shotgunButton.png” - then it moves on to something related to sprites.

“As far as impressiveness goes, I’d heard of you long before I’d heard of Carlos, so take from that what you will :wink: (I say you two should settle it Hey Arnold style: giant Q-tips, pool of Jello, balance beam, first one swimming in semisolids has to surrender their impressiveness).”
I’m surprised but pleased - I do my best to promote Corona (I love it!) and that means I’m doing a good job.

I’d be all for settling things in that manner if it weren’t for the fact Carlos would undoubtedly win and jello is sticky :wink:

“And for the captain. I request a parlay. We can settle this like gentlemen.”
The Captain is actually quite insane, so it’s 50/50 you get your parlay or you walk the plank :wink: [import]uid: 52491 topic_id: 16923 reply_id: 63970[/import]

Well that’s interesting. Why doesn’t that discrepancy cause errors on my system?

And if the captain breaks the pirate’s code, I’ll just come back as a fish pirate ghost and haunt his crazy self. [import]uid: 89724 topic_id: 16923 reply_id: 64011[/import]

I’m actually not totally sure why you aren’t getting any errors - I’m using .591 too. Are you on Windows or Mac?

As to haunting him, you wouldn’t want to do. I’m fiercely loyal and would be forced to vacuum you up, just like Casper :frowning: [import]uid: 52491 topic_id: 16923 reply_id: 64196[/import]

I’m using Windows 7.

And I’d be a fish ghost pirate. They’re corporeal and vacuum proof. Also we have krakens, who tend to eat ghostbusters, vacuum and all. [import]uid: 89724 topic_id: 16923 reply_id: 64205[/import]

That’s good to know - you get zero errors on that last link posted?

I’ll check it out in a bit on a W7 machine and see what happens.

As to the pirate talk, I’ll be watching the newest Pirates DVD tomorrow night and may think of you if a Kraken is involved.

… wait, you’re going to be part fish, now? [import]uid: 52491 topic_id: 16923 reply_id: 64453[/import]

OK I took a look.

Apparently we aren’t showing errors on Windows for capitalization issues - however it’s still very important that you always use perfect capitalization.

You have the following errors with that;
main.lua errors;
Lines 298 and 302 “shotgunbutton.png” should be “shotgunButton.png”

Line 660 “fireX2.png” should be “FireX2.png”

Line 714 “A monotonic day.wav” should be “A monotonic day.WAV”

Line 716 “Complete.wav” should be “Complete.WAV”

Make those changes and you’re all good - just watch the caps in the future, if they’re wrong it can cause issues on device.

Peach :slight_smile: [import]uid: 52491 topic_id: 16923 reply_id: 64460[/import]

Zero errors.

Thanks.

Yeah, Davy Jones and his fish pirate crew had a kraken in the second movie. I haven’t seen the third.

And if you’re a part of Davy’s crew, you’re going to have barnacles and starfish and such stuck to you.

Nice avvie, by the way. [import]uid: 89724 topic_id: 16923 reply_id: 64461[/import]

Ok, thanks. I’ll fix that right away.

Besides capitalization, were there any places where the code could have been improved, possibly streamlined?

Thanks again. [import]uid: 89724 topic_id: 16923 reply_id: 64462[/import]

I’m not sure how this one will be with only Johnny Depp remaining - but we’ll see. (I like him, I just like Keira Knightley too.)

As to your project, I didn’t look at that side of things - mostly because that’s a service we offer under Premium Support and it wouldn’t be fair to paying users. (Link above the reply box if you’re interested.)

Peach :slight_smile:

[import]uid: 52491 topic_id: 16923 reply_id: 64571[/import]