this is my code .. I'm not very handy .. I'm trying to learn! I can not seem to occur in the collision between the enemy and the

require “sprite”
require ‘physics’
physics.start()
physics.setGravity(0,0)
local grabber = require(“SpriteGrabber”)

local StickLib = require(“lib_analog_stick”)

local update = {}

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})
local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scene

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MONTAGNE
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );

– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .5
player.y = screenH* .5
physics.addBody(player,‘kynematic’,{bounce = 0})
local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE SHIP
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )
local bullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + 60
bullet.y = player.y

transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})
bullets.insert(bullets, bullet)
end

rect:addEventListener(‘tap’, bullet)

local enemy = display.newImage(‘enemy.png’)
enemy.y = math.floor(math.random() * (display.contentWidth/2 - enemy.width))
enemy.x = display.contentHeight - 20
enemy.name = ‘enemy’
physics.addBody(enemy)
enemy.bodyType = ‘static’
enemies.insert(enemies, enemy)
enemy:addEventListener(‘collision’, onCollision)

function onCollision( self, event )
if ( event.phase == “began” ) then
if( event.other.objectName ==“enemy” ) then
event.target:removeSelf()
event.other:removeSelf()
bullet:removeEventListener( “collision”, bullet )
end

end
end
[import]uid: 99231 topic_id: 20872 reply_id: 320872[/import]

Hi valerio.innorta, try this approach, it works for me.

function onCollision( self, event )  
 if ( event.phase == "began" ) then  
 if( event.other.objectName =="enemy" ) then  
 self:removeSelf();  
 self = nil;  
 event.other:removeSelf();  
 event.other = nil;  
-- No need to remove the event listener, that is removed when you remove the object that is associated with it. Enterframe events must be removed manually though.  
 end  
 end  
end   

I also noticed something in your code you wrote enemy:addEventListener(‘collision’,onCollision) you need " " not ’ ’ . I hope that helps.
[import]uid: 116225 topic_id: 20872 reply_id: 82368[/import]

hey … thanks a lot for your quick answer to the question! but the problem remains: my game is set

orientation =
{
default = “landscapeRight”,
},

I’d like to bring up the enemy with a kind of transition from right to left, and also when my projectile is launched, the bullet passes over the enemy without touching it … why? seen that the enemy is a physical object? I wait your answer thanks a lot =)
[import]uid: 99231 topic_id: 20872 reply_id: 82442[/import]

So your working on a left to right shooter, good one! my favorite type of shooter.

I realised I forgot to add how I deal with the Physics:

physics.addBody(enemy, { isSensor = true });  

Write this line of code where you declare your enemy, do the same thing for bullets. Now the enemy and bullet don’t have physics properties, they can now be used just to sense collisions.

Do you want your enemy to follow a straight path from left to right? if So, you just need to give it a velocity in the negative x-direction for your game, so:

enemy:setLinearVelocity(-50,0); -- (x\_velocity,y\_velocity)  

Hope this works.

[import]uid: 116225 topic_id: 20872 reply_id: 82601[/import]

nothing to do … applying to the projectile and the enemy is.Sensor = true, the two pass over without touching … I am going crazy! I would also like to create a function that generates my enemies that come out right, but I can not do that! please help me [import]uid: 99231 topic_id: 20872 reply_id: 82707[/import]

Hmmm, that is irritating, I had major problems with collisions when I started out too. Could you upload your game so far to a website and post the link here? It would be easier for me to take a look at. [import]uid: 116225 topic_id: 20872 reply_id: 82852[/import]

I am, sorry for the delay but I worked on my game in a different way.
I created a SPRITE SHEET for my enemy, but I would like to have a random number of enemies that come at a random position on screen. Also I just can not understand how to function on COLLISION, all my attempts seem vain! I put my code, I hope you able to help =)
[lua] require “sprite”
local grabber = require(“SpriteGrabber”)
local movieclip = require “movieclip”

require ‘physics’
physics.start()
physics.setGravity(0,0)

local StickLib = require(“lib_analog_stick”)

local enemiesTable = {}

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})
local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scene

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MONTAGNE
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );

– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .2
player.y = screenH* .5
physics.addBody(player,‘kynematic’,{bounce = 0})
local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE SHIP
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )

local onbullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + bullet.contentWidth
bullet.y = player.y + 5
physics.addBody(bullet)
bullet.bodyType = ‘static’
transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})

bullet:addEventListener(‘collision’, onCollision)
end

rect:addEventListener(‘tap’, onbullet)

myAnim = movieclip.newAnim{ “e1.png”, “e2.png”, “e3.png”, “e4.png”, “e5.png”, “e6.png” }
myAnim.x = 440
myAnim.y = math.random(0, 420)
physics.addBody(myAnim, ‘dynamic’,{rotation = false, bounce = 0})
myAnim:setLinearVelocity(-100,0)
myAnim:play{ startFrame=1, endFrame=6, loop=0, remove=false }
[lua] [import]uid: 99231 topic_id: 20872 reply_id: 84011[/import]

I spawn random enemies on a screen in the game I’m working on right now, so I can help you out there.

What you want to do first is create a function to spawn an enemy, say

local ufo = {} -- Use as array to store each ufo.  
local numberUfos; -- Use to keep track of number of ufo's in array.  
spawnUFO = function()  
numberUfos = #numberUfos+1; -- indexing of arrays starts at 1. The # grabs the current size of the array.   
-- Display image, position, set scale etc.  
ufo[numberUfos].myName = "ufo"; -- important for collision detection.  
physics.addBody( ufo[numberUfos], { isSensor = true }); -- no physics properties are activated, but can be used to sense collisions.  
  
-- You can prepare and play your sprite sheet here too.  
end  

To spawn random enemies, create a function using math.random and call this function with a timer. You will need to adjust the ufo function so as to allow coordinates to be passed in, that is simple enough though.

spawnEnemies = function()  
x1 = math.random;  
y1 = math.random;  
spawnUfo(x1,y1);  
end  
timer.performWithDelay(500,spawnEnemies,0);  

Basic functionality, but gives you the general idea of what you can do.
Now as for the collision detection. I notice you are using tap events, I’m not familiar with those, but I think it is a good practice to be using touch events as you have more flexibility.

function rect:touch(event)  
 if(event.phase == "began") then -- when the button is initially pressed, execute this code. (Works as a tap).  
 bullet = display.newImage("bullet.png")  
 bullet.x = player.x + bullet.contentWidth  
 bullet.y = player.y + 5  
 physics.addBody(bullet, {isSensor = true})   
 bullet:setLinearVelocity(300,0); -- Try playing around with this as opposed to transitions, much simpler and I think it is easier on the memory usage. The first parameter is the x-component of the velocity, the second is the y-component.  
  
bullet.collision = onCollision; -- If a collision is detected, fire the function onCollision.  
bullet:addEventListenr( "collision", bullet );  
end   
rect:addEventListener('touch', onbullet)  

Now you need the onCollision function.

local function onCollision( self, event ) -- self is the bullet.  
 if(event.phase == "began") -- they collided  
 if(event.other.myName == "ufo") then  
 self:removeSelf();  
 self = nil;  
 event.other:removeSelf();  
 event.other = nil;  
 end  
 end  
end  

The above code is basic collision detection, as soon as they hit they are both removed.
[import]uid: 116225 topic_id: 20872 reply_id: 84084[/import]

Forgive me, my mistake not to tell you that my UFO is only the landscape background that moves! Unfortunately I changed my code so many times! my enemy is myAnim.
I created a sprite sheet of the enemy … and now I’m trying to implement your code by modifying it according to my needs! I hope to be able to ADJUST the code … I always wait your answers.
sorry again if I did not understand …
[import]uid: 99231 topic_id: 20872 reply_id: 84188[/import]

There are errors where you add the player to the physics.

You spelled “kinematic” wrong. In your code it is “kynematic”

Regards Joakim
[import]uid: 81188 topic_id: 20872 reply_id: 84201[/import]

[lua]require “sprite”
local grabber = require(“SpriteGrabber”)
local movieclip = require “movieclip”

require ‘physics’
physics.start()
physics.setGravity(0,0)

local StickLib = require(“lib_analog_stick”)

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})

local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scenes

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MOUNTAIN
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );
– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .2
player.y = screenH* .5
physics.addBody(player,‘dynamic’,{bounce = 0})

– RECTANGLE FOR SHOOT

local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE PLAYER
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )
– SHOOT BULLET WITH TRANSITION

local onBullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + bullet.contentWidth
bullet.y = player.y + 5
physics.addBody(bullet,{isSensore = true})
transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})
bullet.collision = onCollision; – If a collision is detected, fire the function onCollision.
bullet:addEventListenr( “collision”, bullet );
end

rect:addEventListener(‘tap’, onBullet)
– MY ENEMY SPRITE SHEET

myEnemy = movieclip.newAnim{ “e1.png”, “e2.png”, “e3.png”, “e4.png”, “e5.png”, “e6.png” }
myEnemy.x = 440
myEnemy.y = math.random(0, 420)
myEnemy.name = ‘enemy’
physics.addBody(myEnemy, {isSensor= false, rotation = false, bounce = 0})
myEnemy:setLinearVelocity(-100,0)
myEnemy:play{ startFrame=1, endFrame=6, loop=0, remove=false }
myEnemy:insert(myEnemy, enemies)

[lua] [import]uid: 99231 topic_id: 20872 reply_id: 84205[/import]

[lua]require “sprite”
local grabber = require(“SpriteGrabber”)
local movieclip = require “movieclip”

require ‘physics’
physics.start()
physics.setGravity(0,0)

local StickLib = require(“lib_analog_stick”)

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})

local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scenes

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MOUNTAIN
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );
– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .2
player.y = screenH* .5
physics.addBody(player,‘dynamic’,{bounce = 0})

– RECTANGLE FOR SHOOT

local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE PLAYER
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )
– SHOOT BULLET WITH TRANSITION

local onBullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + bullet.contentWidth
bullet.y = player.y + 5
physics.addBody(bullet,{isSensore = true})
transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})
bullet.collision = onCollision; – If a collision is detected, fire the function onCollision.
bullet:addEventListenr( “collision”, bullet );
end

rect:addEventListener(‘tap’, onBullet)
– MY ENEMY SPRITE SHEET

myEnemy = movieclip.newAnim{ “e1.png”, “e2.png”, “e3.png”, “e4.png”, “e5.png”, “e6.png” }
myEnemy.x = 440
myEnemy.y = math.random(0, 420)
myEnemy.name = ‘enemy’
physics.addBody(myEnemy, {isSensor= false, rotation = false, bounce = 0})
myEnemy:setLinearVelocity(-100,0)
myEnemy:play{ startFrame=1, endFrame=6, loop=0, remove=false }
myEnemy:insert(myEnemy, enemies)

[lua] [import]uid: 99231 topic_id: 20872 reply_id: 84206[/import]

[lua]require “sprite”
local grabber = require(“SpriteGrabber”)
local movieclip = require “movieclip”

require ‘physics’
physics.start()
physics.setGravity(0,0)

local StickLib = require(“lib_analog_stick”)

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})

local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scenes

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MOUNTAIN
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );
– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .2
player.y = screenH* .5
physics.addBody(player,‘dynamic’,{bounce = 0})

– RECTANGLE FOR SHOOT

local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE PLAYER
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )
– SHOOT BULLET WITH TRANSITION

local onBullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + bullet.contentWidth
bullet.y = player.y + 5
physics.addBody(bullet,{isSensore = true})
transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})
bullet.collision = onCollision; – If a collision is detected, fire the function onCollision.
bullet:addEventListenr( “collision”, bullet );
end

rect:addEventListener(‘tap’, onBullet)
– MY ENEMY SPRITE SHEET

myEnemy = movieclip.newAnim{ “e1.png”, “e2.png”, “e3.png”, “e4.png”, “e5.png”, “e6.png” }
myEnemy.x = 440
myEnemy.y = math.random(0, 420)
myEnemy.name = ‘enemy’
physics.addBody(myEnemy, {isSensor= false, rotation = false, bounce = 0})
myEnemy:setLinearVelocity(-100,0)
myEnemy:play{ startFrame=1, endFrame=6, loop=0, remove=false }
myEnemy:insert(myEnemy, enemies)

[lua] [import]uid: 99231 topic_id: 20872 reply_id: 84207[/import]

[lua]require “sprite”
local grabber = require(“SpriteGrabber”)
local movieclip = require “movieclip”

require ‘physics’
physics.start()
physics.setGravity(0,0)

local StickLib = require(“lib_analog_stick”)

– DISPLAY
_W = display.contentWidth
_H = display.contentHeight
local screenW = display.contentWidth
local screenH = display.contentHeight
local Text = display.newText( " ", screenW*.6, screenH-20, native.systemFont, 15 )

– HIDDEN STATUS BAR
display.setStatusBar(display.HiddenStatusBar)
–MULTITOUCH
system.activate( “multitouch” )
– Background
local baseline = display.contentHeight/2

local sky = display.newImage(“sky.jpg”)
local enemies = display.newGroup()

– BORDER

local borderDown = display.newRect(0, baseline + 140 ,480, 100)
borderDown:setFillColor(255,255,255,0)
physics.addBody( borderDown, ‘static’,{bounce = 1, friction = 0})

local borderUp = display.newRect(0, -60,480, 90)
borderUp:setFillColor(255,255,255,0)
physics.addBody( borderUp, ‘static’,{bounce = 1, friction = 0})

local borderLeft = display.newRect(0, 0, 20, _H)
borderLeft:setFillColor(255,255,255,0)
physics.addBody( borderLeft, ‘static’,{bounce = 1, friction = 0})

local borderRight = display.newRect(_W - 20, 0, 20, _H)
borderRight:setFillColor(255,255,255,0)
physics.addBody( borderRight, ‘static’,{bounce = 1, friction = 0})

– Scenes

local ufo = {}
ufo[1] = display.newImage(“mountain_big.png”)
ufo[1].xScale = 1.7; ufo[1].yScale = 0.7
ufo[1]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[1].x = 50; ufo[1].y = baseline - 125
ufo[1].dx = 0.1

ufo[2] = display.newImage(“mountain_small.png”)
ufo[2].xScale = 0.6; ufo[2].yScale = 0.6
ufo[2]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[2].x = 120; ufo[2].y = baseline + 100
ufo[2].dx = 0.2

ufo[3] = display.newImage(“Bamboo-rgba.png”)
ufo[3].xScale = 0.4; ufo[3].yScale = 0.4
ufo[3]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[3].x = 480; ufo[3].y = baseline + 140
ufo[3].dx = 0.7

ufo[4] = display.newImage(“mountain_small.png”)
ufo[4].xScale = 0.7; ufo[4].yScale = 0.7
ufo[4]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[4].x = 250; ufo[4].y = baseline + 100
ufo[4].dx = 0.4

ufo[5] = display.newImage(“Palm-arecaceae.png”)
ufo[5].xScale = 0.7; ufo[4].yScale = 0.7
ufo[5]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[5].x = 180; ufo[4].y = baseline + 100
ufo[5].dx = 0.6

ufo[6] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[6].xScale = 0.7; ufo[4].yScale = 0.7
ufo[6]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[6].x = 290; ufo[4].y = baseline + 100
ufo[6].dx = 0.4

ufo[7] = display.newImage(“Greenhouse-Palm-jubaea01.png”)
ufo[7].xScale = 0.8; ufo[4].yScale = 0.7
ufo[7]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[7].x = 210; ufo[4].y = baseline + 110
ufo[7].dx = 0.5

ufo[8] = display.newImage(“Bamboo-rgba.png”)
ufo[8].xScale = 0.4; ufo[8].yScale = 0.4
ufo[8]:setReferencePoint(display.BottomCenterReferencePoint)
ufo[8].x = 100; ufo[8].y = baseline + 150
ufo[8].dx = 0.7

– MOUNTAIN
local mountain_big = display.newImage(“mountain_big.png”, 132-150, 0)
local mountain_sma = display.newImage(“mountain_small.png”,-10, 161)
local mountain_big = display.newImage(“mountain_big.png”, 250, 40)
local mountain_sma = display.newImage(“mountain_small.png”, 300, 135)
local mountain_big = display.newImage(“mountain_big.png”,50,80)

– GRASS
local grass = display.newImage( “grass.png” )
grass:setReferencePoint( display.CenterLeftReferencePoint )
grass.x = 0
grass.y = baseline + 150
local grass2 = display.newImage( “grass.png” )
grass2:setReferencePoint( display.CenterLeftReferencePoint )
grass2.x = 480
grass2.y = 300

–GROUND
local ground = display.newRect( 0, baseline + 150, 480, 90 )
ground:setFillColor( 0x31, 0x5a, 0x18 )
local tPrevious = system.getTimer()
local function move(event)
local tDelta = event.time - tPrevious
tPrevious = event.time

local xOffset = ( 0.4 * tDelta )

grass.x = grass.x - xOffset
grass2.x = grass2.x - xOffset

if (grass.x + grass.stageWidth) < 0 then
grass:translate( 480 * 2, 0)
end
if (grass2.x + grass2.stageWidth) < 0 then
grass2:translate( 480 * 2, 0)
end

local i
for i = 1, #ufo, 1 do
ufo[i].x = ufo[i].x - ufo[i].dx * tDelta * 0.2
if (ufo[i].x + ufo[i].stageWidth) < 0 then
ufo[i]:translate( 480 + ufo[i].stageWidth * 2, 0 )
end
end
end
– Start everything moving
Runtime:addEventListener( “enterFrame”, move );
– PLAYER

local player = display.newImage(“goku1.png”)
player.name = ‘player’
player.x = screenW* .2
player.y = screenH* .5
physics.addBody(player,‘dynamic’,{bounce = 0})

– RECTANGLE FOR SHOOT

local rect = display.newRect(_W/2 + 93,_H/2,_W/2+ 150, _H/2)
rect:setFillColor(255,255,255, 30)
–Joystick/Player Movement

MyStick = StickLib.NewStick(
{
x = screenW*.1,
y = screenH*.85,
thumbSize = 16,
borderSize = 32,
snapBackSpeed = .75,
R = 255,
G = 255,
B = 255
} )

MyStick2 = StickLib.NewStick(
{
–x = screenW*.1,
–y = screenH*.85,

x = 550,
y = 850,

–Thumb size is inner circle, border size is outer circle

thumbSize = 40,
borderSize = 64,
snapBackSpeed = .75,
R = 255,
G = 0,
B = 0
} )

local function main( event )

– MOVE THE PLAYER
MyStick:move(player, 10.0, false)
MyStick2:move(player, 7.0, true)

– SHOW STICK INFO
Text.text = “ANGLE = “…MyStick:getAngle()…” DISTANCE = “…math.ceil(MyStick:getDistance())…” PERCENT = “…math.ceil(MyStick:getPercent()*100)…”%”

end

Runtime:addEventListener( “enterFrame”, main )
– SHOOT BULLET WITH TRANSITION

local onBullet = function( self, event )
bullet = display.newImage(‘bullet.png’)
bullet.x = player.x + bullet.contentWidth
bullet.y = player.y + 5
physics.addBody(bullet,{isSensore = true})
transition.to(bullet, {x = player.x + 1200, y = player.y, time = 3000})
bullet.collision = onCollision; – If a collision is detected, fire the function onCollision.
bullet:addEventListenr( “collision”, bullet );
end

rect:addEventListener(‘tap’, onBullet)
– MY ENEMY SPRITE SHEET

myEnemy = movieclip.newAnim{ “e1.png”, “e2.png”, “e3.png”, “e4.png”, “e5.png”, “e6.png” }
myEnemy.x = 440
myEnemy.y = math.random(0, 420)
myEnemy.name = ‘enemy’
physics.addBody(myEnemy, {isSensor= false, rotation = false, bounce = 0})
myEnemy:setLinearVelocity(-100,0)
myEnemy:play{ startFrame=1, endFrame=6, loop=0, remove=false }
myEnemy:insert(myEnemy, enemies)

[lua] [import]uid: 99231 topic_id: 20872 reply_id: 84208[/import]