I want that my empty basket(that is a physics body) image should change to different image(say e.g.-basket1 then to basket2 and so on) on collision.Can anybody provide me a suitable solution for that?please..
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
changing image on collision
plug and play code, i hope it will help you
anyway, there's plenty of ways to do that, this is just one of them and i doubt that its best of them, but still better than nothing right?)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | local physics = require("physics") physics.start() local obj1 = display.newCircle(0,0,30) physics.addBody(obj1) obj1.x = 150 obj1.y = 50 obj1.name = "obj1" local basket = display.newRect(0,0,60,60) basket.x = 150 basket.y = 300 physics.addBody(basket, "static") local basket2 = display.newRect(0,0,30,30) basket2.x = 150 basket2.y = 300 basket2.isVisible = false local function onCollision(self, event) if event.phase == "began" and event.other.name == "obj1" then self:removeSelf() self = nil basket2.isVisible = true local function one() physics.addBody(basket2, "static") end timer.performWithDelay(50, one,1) end end basket.collision = onCollision basket:addEventListener("collision", basket) |
Thanks for the reply .But the problem is that my object is moving .Now How can i have an moving object to change on collision?please help....
Looks like a job for spriteInstance.currentFrame to me. See if this looks like what you need. Just advance the frame as needed.
Could you cite some examples where i can get in more details regarding this?I have a bit of hesitation in using sprites..
dont hesistate using sprites, they are great and easy to use
i would definetly reccomend using sprites, not only they great for what you need,but they can help you manage memory usage of device as well and performance
Please provide me some samples example if you can except for the samples that are available in the Sample Code of corona if you can so that I can understand better.
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
URGENT!: We lost our VFX Artist - still need one (1!) more VFX to ship our game!
addd event listener to nothing
fogbugz bug tracker link and search problem
Textureswitching, Spritesheets, Performance, Static 'sprites', TextureAtlas -- the graphics pipeline
iOS simulator crash
GAME: Green X
test - ignore
Now Available - Airsoft Helper
Stack Trace Repeating Twice In Console